mercredi 25 février 2015

file_get_contents() -> SSL operation failed with code 1

I had this piece of code to get the likes of a particular Facebook page in production since years:



$url = 'http://ift.tt/1AruOgf site id>';
echo json_decode(file_get_contents($url))->{'likes'};


Now we upgraded to PHP 5.6 and it stopped working with the following error message:



Warning: file_get_contents() [function.file-get-contents.php]: SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in <some page> on line 182

Warning: file_get_contents() [function.file-get-contents.php]: Failed to enable crypto in <some site> on line 182

Warning: file_get_contents(http://ift.tt/1AruOgf site id>) [function.file-get-contents.php]: failed to open stream: operation failed in <some page> on line 182


Is there a simple way to fix this?


I know there is a referenced answer but this answer disables SSL verification and I don't want to implement a possible security hole!


Aucun commentaire:

Enregistrer un commentaire