Recaptcha: php 5.6 Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086

Created on 20 Dec 2015  路  11Comments  路  Source: google/recaptcha

recaptcha not work properly on php 5.6 (php 5.5 work fine)
Verify the response string, i got error:
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in Post.php line 69
Warning: file_get_contents(): Failed to enable crypto in...

php

Most helpful comment

It's mine worked.
look at this example

https://php.net/manual/en/migration56.openssl.php

<?php
$arrContextOptions=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);  

$response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042+N+1050+W&outFields=*&outSR=102100&searchExtent=&f=json", false, stream_context_create($arrContextOptions));

echo $response; ?>

All 11 comments

bump +1

+1

I'm running PHP 5.6.25 (latest at present), and file_get_contents() works fine with google API service.

Check your OpenSSL version, perhaps you are running an obsolete one.

Also, try to switch to curl.

With curl you can disable endpoint certificate verification.

curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0);

im getting this when serving to test with homestead which uses vagrant. Is there something i need to enable in vagrant config, such as a port 443 passthrough, or vagrant sharing or something?

Same error on PHP 7.0.x

I'm currently updating the library on the v1.2 branch. Could you point me to an example where this is happening as I'm not able to reproduce it here.

stamster's idea work for me on PHP 5.6.

Try making use of some of the alternate request methods:

// uses http://php.net/fsockopen
$recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\SocketPost());
// uses http://php.net/curl_exec
$recaptcha = new \ReCaptcha\ReCaptcha($secret, new \ReCaptcha\RequestMethod\CurlPost());

It's mine worked.
look at this example

https://php.net/manual/en/migration56.openssl.php

<?php
$arrContextOptions=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);  

$response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042+N+1050+W&outFields=*&outSR=102100&searchExtent=&f=json", false, stream_context_create($arrContextOptions));

echo $response; ?>

It's mine worked.
look at this example

https://php.net/manual/en/migration56.openssl.php

<?php
$arrContextOptions=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);  

$response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042+N+1050+W&outFields=*&outSR=102100&searchExtent=&f=json", false, stream_context_create($arrContextOptions));

echo $response; ?>

Yes it is working. Thanks alicompu

verify_peer=false

It's not a good practice to disable verify_peer. A better solution to this problem:

  1. Upgrade OpenSSL

  2. Set OpenSSL bundle path in php.ini:

    openssl.cafile=/usr/local/etc/openssl/cert.pem

Was this page helpful?
0 / 5 - 0 ratings