reCAPTCHA Error – Blocked Loading Mixed Active Content

This article is intended for developers using reCAPTCHA Library for PHP (recaptcha-php-1.11).

Problem

When I access my website over SSL, Google Recaptcha doesn’t load.

When I access the javascript error console, I see the following error:

Blocked loading mixed active content
“https://www.google.com/recaptcha/api/challenge?k=KEY-GOES-HERE” [Learn More]

What causes this problem?

You will see the Blocked loading mixed active content error when accessing your website over https (ssl) but calling Google’s recaptcha using http (no ssl). Your browser is blocking the insecure content which is trying to load over http (no ssl).

Solution

The solution to this problem is to use SSL when calling the recaptcha_get_html function to create your recaptcha form.

If you look at around line 106 of recaptcha-php-1.11/recaptchalib.php, you’ll see the function has an optional ssl parameter:

 function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)

Changing your code from the red example below to the green example below should fix this error for you:

 $recaptcha = recaptcha_get_html($publickey); $recaptcha = recaptcha_get_html($publickey,'',true);

0 thoughts on “reCAPTCHA Error – Blocked Loading Mixed Active Content

  1. Although I could find:

    function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)

    in recaptchalib.php

    I could not find:

    $recaptcha = recaptcha_get_html($publickey);

    However changing

    define("RECAPTCHA_API_SERVER", "https://www.google.com/recaptcha/api");
    define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
    define("RECAPTCHA_VERIFY_SERVER", "https://www.google.com");

    to

    define("RECAPTCHA_API_SERVER", "https://www.google.com/recaptcha/api");
    define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
    define("RECAPTCHA_VERIFY_SERVER", "https://www.google.com");

    worked.

    Thank you

Was this article helpful? Join the conversation!