从昨晚开始,我使用file_get_contents("https://...")和curl函数的几个脚本(在不同的服务器上)停止工作。
失败的示例请求:
file_get_contents("https://domain.tld/script.php");误差
PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /home/domain/public_html/script.php on line 19我已经用以下方法“修正”了这个问题:
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
file_get_contents("https://domain.tld/path/script.php", false, stream_context_create($arrContextOptions));“修复”并不理想,因为我没有验证连接的真实性,但是直到我理解问题的根源以及如何防止它再次发生,我才会被迫使用它。
Notes
Curl的PHP脚本也停止工作,修复程序类似:curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);;SSL证书由Let's Encrypt签发,并于昨晚续签(“2020/12/24之前无效”);CentOS 7/Ubuntu 18和Virtualmin;"https://domain.tld/script.php",就不会显示SSL警告,并且证书是有效的;yum install ca-certificates.noarch),但最新版本已经安装;我明白是怎么回事,我搞不懂为什么它开始发生,以及如何修复它(真正的修复)。
问题
如何解决和防止再次发生这种情况?
发布于 2020-12-24 21:53:03
问题是一个过时的CA证书,我在让我们加密社区线程上找到了解决方案:
手动解决方案:
/home/[domain]/ssl.ca的内容替换为lets-encrypt-r3-cross-signed.pemVirtualmin溶液:
Virtualmin -> Server Configuration -> SSL Certificate -> CA Certificate- Option 1: Choose `upload file` and use [lets-encrypt-r3-cross-signed.pem](https://letsencrypt.org/certs/lets-encrypt-r3-cross-signed.pem)
- Option 2: Paste the contents of [lets-encrypt-r3-cross-signed.pem](https://letsencrypt.org/certs/lets-encrypt-r3-cross-signed.pem) using the `Pasted certificate text` option.Save Certificate“

注意:
这个问题是固定在webmin 1.970上,所以确保您已经安装了最新版本,这不是我的情况,因为webmin回购没有启用。如果这也是您的情况,只需启用或添加webmin并运行yum update。
https://stackoverflow.com/questions/65442972
复制相似问题