使用 file_get_contents 突然出现 OpenSSL 错误消息:错误:14090086

ome*_*ga1 14 php openssl file-get-contents

我已经搜索了此错误的问题,但我对我自己的许多已开始显示此错误的服务器之间可能发生的情况感到困惑:

Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /var/www/html/file_get.php on line 7
Run Code Online (Sandbox Code Playgroud)

第 7 行是 file_get_contents 命令。

这些是我控制下的(Debian)服务器,所以我知道(据我所知)没有发生/更改或更新/升级。

我知道我可以使用包含以下内容的解决方案,但我很想了解首先发生了什么(加上我有很多很多文件需要更新)。我还真的需要了解哪台服务器存在潜在问题。

我有 3 台服务器,所有这些服务器都通过 file_get_contents 请求访问另一台第四台服务器。其中 2 个服务器突然(今天几个小时前)开始出现上述错误,第三个服务器似乎仍然工作正常。

我怀疑问题出在显示问题的两台服务器上,而不是它们都试图访问的第四台服务器上。

如果我实现这段代码,它会起作用,但我宁愿找到根本原因:

$arrContextOptions=array(
    "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),
);  
Run Code Online (Sandbox Code Playgroud)

并将 file_get_contents 修改为以下内容:

file_get_contents($input, false, stream_context_create($arrContextOptions)));
Run Code Online (Sandbox Code Playgroud)

但正如前面提到的,我有数百个文件需要更改。

所有服务器都是 Debian 并使用 Lets Encrypt 证书 9(这是有效的)。

我尝试将以下内容添加到 php.ini:

openssl.cafile=/etc/letsencrypt/live/myserver.com/cert.pem
Run Code Online (Sandbox Code Playgroud)

但这并没有奏效(同样的错误仍然存​​在)。

仍然有效的服务器的 openssl 版本是 OpenSSL 1.1.0f 25 May 2017 (库:OpenSSL 1.1.0l 10 Sep 2019),显示错误的两个是 OpenSSL 1.1.0l 10 Sep 2019 不确定这是否相关。

任何帮助,将不胜感激。

更新

所以到目前为止我已经能够解决这个问题。经过大量的测试和试验后,老实说,我不太确定如何解决问题以确保它再次正常工作,但我做了以下所有操作:

  • apt upgrade
  • apt update
  • 我删除了旧的certbot-auto
  • 已安装certbot(较新版本)
  • mozilla/DST_Root_CA_X3.crt已经从...删除/etc/ca-certificates.conf
  • update-ca-certificates

再次,不确定上述哪一个(或以上的组合)解决了问题,但它现在对我有用。

小智 6

我在 Ubuntu 16.04.7 中也遇到了类似的问题,在我的例子中,当我尝试使用 Postman 进行 GET / POST 时,我收到了 SSL 错误:证书过期消息。

这是解决方案:

  1. 编辑/etc/ca-certificates.conf找到mozilla/DST_Root_CA_x3.crt
  2. !在行首添加sing ie!mozilla/DST_Root_CA_x3.crt
  3. 保存更改,然后更新证书sudo update-ca-certificates
  4. 重新启动服务器

解决方案之前

解决方案之后

  • 非常感谢您提供这个解决方案。它的效果非常好。update-ca-certificates 后,无需重新启动即可修复错误。为什么我们需要重启?目前,数以百万计的网站在文件获取内容以及 sh 中的 wget 方面都存在此问题。我所有的定时任务都不再起作用了。例如生成 ads.txt 的作业。由于这个问题我已经损失了很多钱。感谢您提供此解决方案。如果重新启动已经可以正常工作,请告诉我重新启动是否重要。谢谢。 (2认同)

Mat*_*Von 5

我今天也遇到了同样的问题,网络浏览器中的 nok,邮递员中的 SSL 错误和一些编程语言调用。\n我的错误是由于 root let\'s 加密证书过期\n 请参阅此处的公告

\n

使用 ssllab.com,我们发现我的证书存在两条认证链,\没有一个到 ISRG Root X1,这是可以的\另一个到 DST Root CA X3 自签名过期证书(9 月 30 日 \ xc3\xa0 14:00 (格林威治标准时间)

\n

为了解决这个问题,我通过 snapd 将 certbot 更新到最新版本(1.19)。我的 ubuntu 20.04 的数据包管理器中的那个不是最后一个。(参考certbot 文档

\n

然后我使用选项续订证书: --preferred-chain \'ISRG Root X1\'\n注意:查看 OP 更新,这可能是新版本的 certbot 中的默认设置

\n

并重新启动服务。从那时起一切都好。

\n

还要确认这是您的问题,\n可以通过 ssllabs.com 等在线工具查看证书链

\n

证书失败的示例:

\n
\nCertification Paths\nPath #1: Trusted\n \n1   Sent by server  asp.xyz.com\nFingerprint SHA256: 30c7865bd2fb4541e819bcfba43456b9fee3310b3faa8be8c86bd26a5cd6b15f\nPin SHA256: Iw4x0j6IktVzCyk1DsHyV5h8BuqXIq98VOhwLR0UWww=\nRSA 2048 bits (e 65537) / SHA256withRSA\n2   Sent by server  R3\nFingerprint SHA256: 67add1166b020ae61b8f5fc96813c04c2aa589960796865572a3c7e737613dfd\nPin SHA256: jQJTbIh0grw0/1TkHSumWb+Fs0Ggogr621gT3PvPKG0=\nRSA 2048 bits (e 65537) / SHA256withRSA\n3   In trust store  ISRG Root X1   Self-signed\nFingerprint SHA256: 96bcec06264976f37460779acf28c5a7cfe8a3c0aae11a8ffcee05c0bddf08c6\nPin SHA256: C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=\nRSA 4096 bits (e 65537) / SHA256withRSA\nPath #2: Not trusted (invalid certificate [Fingerprint SHA256: 0687260331a72403d909f105e69bcf0d32e1bd2493ffc6d9206d11bcd6770739])\n \n1   Sent by server  asp.xyz.com\nFingerprint SHA256: 30c7865bd2fb4541e819bcfba43456b9fee3310b3faa8be8c86bd26a5cd6b15f\nPin SHA256: Iw4x0j6IktVzCyk1DsHyV5h8BuqXIq98VOhwLR0UWww=\nRSA 2048 bits (e 65537) / SHA256withRSA\n2   Sent by server  R3\nFingerprint SHA256: 67add1166b020ae61b8f5fc96813c04c2aa589960796865572a3c7e737613dfd\nPin SHA256: jQJTbIh0grw0/1TkHSumWb+Fs0Ggogr621gT3PvPKG0=\nRSA 2048 bits (e 65537) / SHA256withRSA\n3   Sent by server  ISRG Root X1\nFingerprint SHA256: 6d99fb265eb1c5b3744765fcbc648f3cd8e1bffafdc4c2f99b9d47cf7ff1c24f\nPin SHA256: C5+lpZ7tcVwmwQIMcRtPbsQtWLABXhQzejna0wHFr8M=\nRSA 4096 bits (e 65537) / SHA256withRSA\n4   In trust store  DST Root CA X3   Self-signed\nFingerprint SHA256: 0687260331a72403d909f105e69bcf0d32e1bd2493ffc6d9206d11bcd6770739\nPin SHA256: Vjs8r4z+80wjNcr1YKepWQboSIRi63WsWXhIMN+eWys=\nRSA 2048 bits (e 65537) / SHA1withRSA\nValid until: Thu, 30 Sep 2021 14:01:15 UTC\nEXPIRED\nWeak or insecure signature, but no impact on root certificate\n
Run Code Online (Sandbox Code Playgroud)\n


小智 5

我在 CentOS 7 上也遇到过同样的问题。

我的解决方案是:

  1. sudo yum update ca-certificates
  2. grep DST_Root_CA_x3 /etc/ssl/certs/ca-bundle.crt
  3. 删除 DST_Root_CA_x3 证书(如果存在)
  4. 重新启动你的服务

  • 我在 CentOS 7 上也遇到了同样的问题。我使用 Virtualmin,所以我刚刚更新了 `certbot` 和 `ca-certificates` 软件包,之后问题就得到了解决。 (2认同)