google / recaptcha

PHP client library for reCAPTCHA, a free service to protect your website from spam and abuse.
http://www.google.com/recaptcha/
BSD 3-Clause "New" or "Revised" License
3.48k stars 775 forks source link

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

Closed sanluiss closed 6 years ago

sanluiss commented 8 years ago

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...

arcontact commented 8 years ago

bump +1

jstensved commented 8 years ago

+1

stamster commented 8 years ago

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);
brian-lamb-software-engineer commented 7 years ago

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?

endo64 commented 6 years ago

Same error on PHP 7.0.x

rowan-m commented 6 years ago

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.

sanluiss commented 6 years ago

stamster's idea work for me on PHP 5.6.

rowan-m commented 6 years ago

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());
alicompu commented 5 years ago

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; ?>
hafiz-naser commented 5 years ago

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

Moradnejad commented 3 years ago

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

panpic commented 3 years ago

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; ?>

Thank you so much. It's working well on PHP 7.2