SSL routines:tls_process_server_certificate:certificate 验证失败

SSL routines:tls_process_server_certificate:certificate verify failed

从昨晚开始,我的几个使用 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));

“修复”远非理想,因为我没有验证连接的真实性,但在我了解问题的根源以及如何防止它再次发生之前,我将被迫使用它。


备注:


我明白出了什么问题,但我不明白的是它为什么开始发生以及如何修复它(真正的修复)。


问题:

如何解决并防止它再次发生?

问题是过时的 CA 证书,我在 Let's Encrypt community thread 上找到了解决方案:

手动解决方案:

Virtualmin 解决方案:


注:

此问题是 fixed on webmin 1.970, so make sure you've the latest version installed, which wasn't my case due to the webmin repo 未启用。如果您也是这种情况,只需启用或添加 webmin 存储库和 运行 yum update.