Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 views
in Technique[技术] by (71.8m points)

Google Recaptcha check timeout due to IPv6 issue - php on IIS

I'm using google recaptcha v2 on my websites (html / php).

On the server side I am trying to contact google recaptcha to check the user's input:

$response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$privatekey."&response=".$_POST['g-recaptcha-response']);

The line above is not working. It normally just times out. Occasionally it will work though.

IPv6 is the Issue

It appears to be an issue with the call to google resolving to IPv6 (from https://github.com/google/recaptcha/issues/193)

I have tried turning off IPv6 on my internet connection and that makes it work.

How do I fix this issue properly? I don't think I could turn off IPv6 on the servers (we use some shared hosting as well as a VPS). Is there a way to force it to resolve to IPv4?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Issue was that php could not verify the SSL certificate. The IPv4 / IPv6 was a bit of a red herring I think.

Great post here on that: file_get_contents(): SSL operation failed with code 1. And more


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...