Answer the question
In order to leave comments, you need to log in
Why did file_get_contents stop working?
I have a small script, the essence of which is to use file_get_contents to collect data from one third-party site.
Everything worked fine, but today a third-party site updated its ssl certificate from lets'en crypt on schedule, and my script returns an 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 ...
Answer the question
In order to leave comments, you need to log in
Try using the more flexible stream_context_create options as one of the parameters to the file_get_contents function. Try 'verify_peer' => false.
$url = 'https://secure.example.com/test/1';
$contextOptions = array(
'ssl' => array(
'verify_peer' => true,
'cafile' => __DIR__ . '/cacert.pem',
'verify_depth' => 5,
'CN_match' => 'secure.example.com'
)
);
$sslContext = stream_context_create($contextOptions);
$result = file_get_contents($url, NULL, $sslContext);
IMHO, most likely you need to update the system, since you have an outdated Letsencrypt root cert ( https://techcrunch.com/2021/09/21/lets-encrypt-roo... ).
As far as I understand, these are RPM ca-certificates.
Since October 1, letsencrypt has changed the root certificate, update your version.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question