Answer the question
In order to leave comments, you need to log in
Why is readfile() throwing an ssl error?
Hi all.
Such situation .
There is an API:
API with a self-signed certificate.
There is a code:$url = 'https://x.x.x.x/api.php';
// стандартные опции для отключения проверки SSL
$opts = [
'ssl' => [
'verify_peer' => false,
'verify_peer_name' => false,
]
];
$context = stream_context_create($opts);
// данная функция работает нормально без проблем
readfile($url,false,$context);
// данный вариант выдает ошибку
// при использования фильтра для потока
stream_filter_register('ssf', 'StringStreamFilter')
readfile('php://filter/ssf/resource=' . $url, false, $context);
Warning : readfile(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in
Answer the question
In order to leave comments, you need to log in
If you're running code locally, the most common cause of broken TLS certificates is antivirus software. Try disabling scanning of secure (encrypted) connections in your antivirus settings.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question