I saw issue #2476057: reCaptcha Verification fails when arg_separator.output is not '&' but this doesn't appear to be the problem for me: I'm encountering this error on a new D7 site, not an upgrade. I've also reviewed my settings.php & php.ini files, and the problematic configuration is not there.

I've been encountering this error ever since the beta1 release - before that the NoCAPTCHA function worked correctly on this site. I've attempted to clear caches, disable and re-enable the module to no avail. I continue to see the error in the title.

What steps should I take to investigate where this error is coming from? Is there a debug mode I can enable, or is there some code I can add to emit some debug code that will give me more information about what's causing the error?

Comments

safetypin’s picture

Issue summary: View changes
safetypin’s picture

Issue summary: View changes
hass’s picture

Can you first check if there are errors shown on status page?

If not, you may check watchdog if there is something useful.

Do you require curl? Is fsocket locked down? Try to debug the response from google. As it works here properly I tend to believe an fsocket issue or any other lockdown issue.

safetypin’s picture

No errors on the status page.

I checked recent log messages, and I couldn't find anything that seemed useful, but I just noticed after logging in this morning that I am still seeing error messages when logging in:

CAPTCHA problem: unexpected result from hook_captcha() of module recaptcha when trying to retrieve challenge type reCAPTCHA for form user_login.

And the weird thing about this is: the recaptcha module is currently disabled, and has been since last night, but this message was logged this morning when I logged in.

--

I'm not sure how to check on "requiring curl" or if fsocket is locked down. I'm familiar with using curl to make requests in PHP, but I don't know what you mean by "Do you require curl?" I'll do a google search for fsocket and see if I can figure it out.

If there's a potential issue with the server configuration, then that seems like the most likely culprit - it's setup on a VPS and I'm using nginx as my web server. What's the best way for me to debug the response from Google? Can I put a "print_r()" statement somewhere in the nocaptcha module code to print it?

safetypin’s picture

So, I just saved the CAPTCHA config page, and cleared cache, and I think that error message I mentioned above won't happen again - I wasn't seeing any CAPTCHA when logging in before, and now I see the Math CAPTCHA, so that's probably just a caching issue. I'll look into fsocket and come back when I've done more testing.

hass’s picture

- Update module works for you?
- Check if fsockopen and others may be blocked on your host.

Debugging may be required at $recaptcha->verify() in .module file and maybe the 6 lines above where the $recaptcha is inited. If it is not there you need to dive down into the library recaptcha-php to find what function is not working.

Please let me know if you found the root cause. I'm already checking some things in hook_requirement(), but it looks like we need to check more :-(((

Liam Morland’s picture

Issue summary: View changes

Formatting of issue link.

hass’s picture

Feel free to also try #2473141: Add cURL support and configure with cURL.

I had issues with SSL, but when I set CURLOPT_SSL_VERIFYPEER => false in Curl.php it works. This means cURL has a missing root CA, but it is worth a try.

I also have a Request class ready that is based on Drupal 7 core only. This may be the last try.

hass’s picture

@safetypin: Can you also try out #2481161: Implement RequestMethod based on drupal_http_request(), please? I feal like we get rid of all the Google library issues we have with HTTP requests as it uses Drupals internal http request functions that are well known. We can also remove the hook_requirement checks than I think.

I guess we will cut another rc2 with this as it really changes a central piece of code.

safetypin’s picture

Category: Bug report » Support request
Status: Active » Closed (cannot reproduce)

Okay, this is weird. Apparently I didn't have the public & secret keys saved correctly. After checking some of the things you suggested, and applying the curl patch with no success, I just went in and looked at the config page, and noticed that the public key was missing. Not sure how that happened. So I saved it, and it still didn't work, so I went into the .module file to debug, and although it looked like the verify function wasn't even running, it actually was just failing immediately because it didn't have a secret key.

So I went back into the config page, and the secret key was missing. I'm positive the secret key was there earlier, and I didn't do a database reset or anything. I did downgrade/upgrade the module, and when I first started running into problems, I downgraded to the 1.12 version. So, maybe when I downgraded the keys got removed from the database.

Anyway, I feel like an idiot, because now it's working properly. I've tested it on my mac laptop and my VPS (running nginx) and everything is working correctly. Sorry!

hass’s picture

That is strange. If the site key is missing it need to fallback to Math captcha. Have you had a site key, but no secret key or both missing? Code wise if the site key is inside and the secret not than this may be possible. This could only be upgrade issues than as the form require that you enter both values.

Can you clarify this, please? I could add an additional check for secret key, too so it safely fallback to Math captcha. This is old code I have not touched. May not that reliable...

If you switch back from 1.x and 2.x without clean uninstall you will run into troubles as variable names have all changed.

We may be missing a cache clear all in the 1.x to 2.x upgrade function and update.php does not run this...

hass’s picture

Status: Closed (cannot reproduce) » Postponed (maintainer needs more info)

  • hass committed f78eec6 on 8.x-2.x
    Issue #2479871 by hass: Require both site key and secret key set or...

  • hass committed a462fed on
    Issue #2479871 by hass: Require both site key and secret key set or...

  • hass committed 2309fe2 on
    Issue #2479871 by hass: Require both site key and secret key set or...
hass’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
schiavone’s picture

I've had mixed results on different sites. Saw message on status report...

Please check your site sites/default/settings.php file and remove the invalid PHP setting ini_set('arg_separator.output', '&');. This is a leftover from Drupal 5/6 in-place upgrades and causes malfunctions in the reCAPTCHA module. Please see known issue with arg_separator.output for more information.

Made sense so I copied over settings.php from a fresh D7 install and flushed cache. But still getting the "The answer you entered for the CAPTCHA is not correct" message.

ghobadipouya’s picture

Component: reCAPTCHA Captcha » General

The answer you entered for the CAPTCHA was not correct.
this is my site error in exposed views drupal
Ive used "Im not robot" recaptcha
the recaptcha work well in login... but not work in exposed views drupal
please help me....