代码之家  ›  专栏  ›  技术社区  ›  Pedro Lobito

SSL协议routines:tls_process_server_certificate:证书验证失败

  •  0
  • Pedro Lobito  · 技术社区  · 4 年前

    从昨晚开始,我的几个脚本(在不同的服务器上)使用 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));
    

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


    笔记

    • PHP脚本 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 ),但已安装最新版本;

    我明白出了什么问题,但我搞不清楚的是为什么会发生这种情况,以及如何解决它(真正的解决办法)。


    问题 :

    如何修复并防止再次发生?

    0 回复  |  直到 4 年前
        1
  •  3
  •   Pedro Lobito    4 年前

    Let's Encrypt community thread :

    手动解决方案:

    Virtualmin解决方案:

    • Virtualmin -> Server Configuration -> SSL Certificate -> CA Certificate

    • Save Certificate "

    enter image description here


    注:

    这个问题是 fixed on webmin 1.970 webmin repo 未启用。如果您也是这样,只需启用或添加webmin repo并运行 yum update