Ped*_*ito 10 php ssl curl ssl-certificate virtualmin
从昨晚开始,我的几个使用file_get_contents("https://...")和curl运行的脚本(在不同的服务器上)停止工作。
失败的请求示例:
file_get_contents("https://domain.tld/script.php");
Run Code Online (Sandbox Code Playgroud)
错误:
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
Run Code Online (Sandbox Code Playgroud)
我已经使用以下方法“修复”了该问题:
$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));
Run Code Online (Sandbox Code Playgroud)
“修复”远非理想,因为我没有验证连接的真实性,但在我了解问题的根源以及如何防止它再次发生之前,我将被迫使用它。
注意事项:
Curl也停止工作,修复方法类似:
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"在 Firefox/Chrome 上打开,则不会显示 SSL 警告,并且证书有效;yum install ca-certificates.noarch),但已安装最新版本;我明白出了什么问题,但我无法弄清楚为什么会发生这种情况以及如何修复它(真正的修复)。
问题:
如何修复并防止再次发生?
问题是过时的 CA 证书,我在Let's Encrypt 社区线程中找到了解决方案:
/home/[domain]/ssl.ca为让-加密-r3-cross-signed.pem去Virtualmin -> Server Configuration -> SSL Certificate -> CA Certificate
upload file并使用let-encrypt-r3-cross-signed.pemPasted certificate text。按 ” Save Certificate”
笔记:
此问题已在 webmin 1.970 上修复,因此请确保您安装了最新版本,这不是我的情况,因为webmin 存储库未启用。如果您也是这种情况,只需启用或添加 webmin 存储库并运行yum update。
| 归档时间: |
|
| 查看次数: |
54425 次 |
| 最近记录: |