16

I have been using reCAPTCHA on my site for a while now and suddenly I realized it has stopped to work. The reCAPTCHA is there, however after verifying correctly, the response FAILS which makes the submit of the form fail.

On the client side console, the browser gives an error:

Uncaught (in promise) Invalid Encryption.

I have tried to search for this error but can not find anything similar. After submitting the form, the server side verification in PHP fails. I am not sure if the error above is related, however, it has not been there before.

Example page of client side integration:

<html>
<head>
    <title>reCAPTCHA demo: Simple page</title>
     <script src="https://www.google.com/recaptcha/api.js" async defer> 
</script>
</head>
  <body>
    <form action="?" method="POST">
      <div class="g-recaptcha" data-sitekey="your_site_key"></div>
      <br/>
      <input type="submit" value="Submit">
    </form>
   </body>
</html>

Server side verification PHP:

$response = json_decode( 
    file_get_contents( 
 "https://www.google.com/recaptcha/api/siteverifysecret=MY_SECRET&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR'] ), true );

if($response['success'] == false){
    echo "FAIL";
} else {
    //do something
}

I have followed the instructions found here.

Rolando Isidoro
  • 4,983
  • 2
  • 31
  • 43
Emir Husic
  • 717
  • 5
  • 16

2 Answers2

3

I ran into the same problem yesterday. It looks as though Google has acknowledged the problem and is working toward fixing it. They claim it shouldn't affect the overall function of the reCAPTCHA.

I obtained this information here.

Below is a screen shot of the conversation.

Screen shot of Google forum

SIGSTACKFAULT
  • 919
  • 1
  • 12
  • 31
Jessica
  • 31
  • 2
  • I am confused, it has been working previously and suddenly the validation fails. I did try to implement it on my local web server where reCaptcha validation succeeded (even though the console error persists). However, the website hosted by a web hosting provider (miss-hosting) does not. I use completely identical code (except the tokens ofc) for testing on my local web server and get different results. Strange, strange... – Emir Husic Oct 24 '18 at 17:15
0

Seems like the answer from Jessica answers for the error in the browser. However, additionaly to the error, my reCaptcha validation failed. I updated the PHP version of my web server from 7.0 to 7.1. This solved my issue. So if you have troubles with the verification and not only the error message in the browser, check the PHP version of your web server.

Emir Husic
  • 717
  • 5
  • 16