reCaptcha over SSL
Permalink Browser Info Environment
I'm writing this down because it could save time to someone else and for future memory.
I needed to have reCaptcha challenge via SSL because my site is served via HTTPS. I'm using the wonderful add on reCaptcha which allows you to use reCaptcha instead of SecureImage (concrete5 default).
The problem is that when your site works on HTTPS, if the challenge request is made via simple HTTP the result is that you will not receive any captcha (the challenge image will not show up).
The solution is in the function recaptcha_get_html() contained in the recaptchalib.php file. This function accepts three parameters, but only the first one is mandatory:
The solution for sending the requests via HTTPS is to set the third parameter to true when this function gets called.
It is used in the file recaptcha/models/system/captcha/types/recaptcha/controller.php at line 19, as it is possible to see below:
If you want the requests to be made over SSL, you have to modify that line in this way:
Hope it helps someone.
I don't know if there is a way to set this parameter via some configuration. Maybe I missed something?
Anyway, thanks for the addon.
Cheers.
I needed to have reCaptcha challenge via SSL because my site is served via HTTPS. I'm using the wonderful add on reCaptcha which allows you to use reCaptcha instead of SecureImage (concrete5 default).
The problem is that when your site works on HTTPS, if the challenge request is made via simple HTTP the result is that you will not receive any captcha (the challenge image will not show up).
The solution is in the function recaptcha_get_html() contained in the recaptchalib.php file. This function accepts three parameters, but only the first one is mandatory:
function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
The solution for sending the requests via HTTPS is to set the third parameter to true when this function gets called.
It is used in the file recaptcha/models/system/captcha/types/recaptcha/controller.php at line 19, as it is possible to see below:
echo recaptcha_get_html($keys['recaptcha_key_public']);
If you want the requests to be made over SSL, you have to modify that line in this way:
echo recaptcha_get_html($keys['recaptcha_key_public'],null,true);
Hope it helps someone.
I don't know if there is a way to set this parameter via some configuration. Maybe I missed something?
Anyway, thanks for the addon.
Cheers.
Type: | Discussion |
---|---|
Status: | New |