Recently got this message while I was trying to use get_file_contents in PHP.
file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
This is caused by PHP being unable to verify the certificate as the message says! The reason why it can't verify the certificate is almost certainly related to file certificate authorities file (aka the CA file). Take a look at phpinfo and look for openssl.cafile. If it is empty then this is your problem.
If it's not empty then check that the file exists. If it does then it may be out of date. You can download the latest version from here:
The simplest way to fix this problem is to add the CA file to PHP's configuration (php.ini) with the following line:
There are times when you want to ignore the verification failure such as in a development environment where wasting your life trying to fix SSL related problems is just a distraction from your real work. So here is how you ignore those errors.
$stream_opts = [ "ssl" => [ "verify_peer"=>false, "verify_peer_name"=>false, ] ]; $response = file_get_contents("https://www.example.com", false, stream_context_create($stream_opts));