When recaptcha is added to a page which is using SSL (https) connection you get mixed content messages because recaptch is pulling js from http://api.recaptcha.net/js/recaptcha_ajax.js

There is a secure version of this javascript file here: https://www.google.com/recaptcha/api/js/recaptcha_ajax.js

Perhaps the function recaptcha_captcha could have a check for SSL before running the the drupal_add_js and then select the appropriate js file.

Comments

thebuckst0p’s picture

This needs the new php lib to be swapped in from http://code.google.com/p/recaptcha/downloads/list?q=label:phplib-Latest, then the server URLs will be correct.

puddyglum’s picture

I just replaced
drupal_add_js('http://api.recaptcha.net/js/recaptcha_ajax.js', array('type' => 'external'));
with
drupal_add_js('https://www.google.com/recaptcha/api/js/recaptcha_ajax.js', array('type' => 'external'));
and it works fine. This seriously needs to be patched.

puddyglum’s picture

Status: Active » Closed (duplicate)

Actually, this is in the -dev build already. This is a duplicate of #1124950: reCAPTCHA uses a new HTTPS API URL

cutcopypaste’s picture

I was having this issue, switched to the dev build, cleared caches etc and the ReCaptcha is still causing a 'This page has insecure content' error

defconjuan’s picture

I had a similar issue with another JavaScript library. Here's how I fixed it:

// set the standard include
$pr_trac_js = 'http://example.com/example.js';

// check if site's being accessed over ssl, there's debate on the best way, but this is one
// if so, change the js include to the ssl version
if(!empty($_SERVER["HTTPS"])) {
  if($_SERVER["HTTPS"]!=="off"){
    $pr_trac_js = 'https://example.com/example.js';
    }
}

// build options array (drupal_add_js options info can be found on the interweb)
$pr_trac_opts = array(
        '#type' => 'external',
        '#every_page' => TRUE,
        '#weight' => -1000,
        '#preprocess' => TRUE,
        '#cache' => TRUE,
        '#scope' => 'header'
        );

// do the ditty
drupal_add_js($pr_trac_js, $pr_trac_opts);