file_get_contents(): SSL operation failed with code 1 #aws #apache #xampp #ubuntu
hoy se me presento el siguiente error al implementar en mi vps el recaptcha de google, el error es el siguiente: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 /web/configuracion/captcha.php on line 14 Warning: file_get_contents(): Failed to enable crypto in /web/configuracion/captcha.php on line 14 Warning: file_get_contents(https://www.google.com/recaptcha/api/siteverify?secret=dadkasklklsda23uisjksadkjl&response=&remoteip=55.55.55.55): failed to open stream: operation failed in /opt/lampp/htdocs/web/configuracion/validarCaptcha.php on line 14
codigo original:
1 2 3 4 5 6 7 8 9 | $llave= "dadkasklklsda23uisjksadkjl" ; $ip=$_SERVER[ "REMOTE_ADDR" ]; $captcha=$_POST[ 'g-recaptcha-response' ]; $verificarCaptcha=file_get_contents( "https://www.google.com/recaptcha/api/siteverify?secret=$llave&response=$captcha&remoteip=$ip" ); $arregloCaptcha=json_decode($verificarCaptcha,TRUE); if ($arregloCaptcha[ "success" ]) { return true ; } |
Solución:
1 2 3 4 5 6 7 8 9 10 11 12 | $llave= "dadkasklklsda23uisjksadkjl" ; $ip=$_SERVER[ "REMOTE_ADDR" ]; $captcha=$_POST[ 'g-recaptcha-response' ]; $ch = curl_init( "https://www.google.com/recaptcha/api/siteverify?secret=$llave&response=$captcha&remoteip=$ip" ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true ); $verificarCaptcha = curl_exec($ch); $arregloCaptcha=json_decode($verificarCaptcha,TRUE); if ($arregloCaptcha[ "success" ]) { return true ; } |
la solución fue utilizar curl para poder consultar HTTPS sin problemas.
Fuente: http://stackoverflow.com/questions/11064980/php-curl-vs-file-get-contents
Genial, después de horas navegando y buscando en Google, me he topado con tu pagina, me ha funcionado a la primera.
ResponderEliminarGracias.