【问题标题】:cURL error 60: SSL certificate problem: certificate has expiredcURL 错误 60:SSL 证书问题:证书已过期
【发布时间】:2020-09-18 06:58:26
【问题描述】:

我们在亚马逊 ec2 上运行 2 个应用程序(backend.abc.comfrontend.abc.com)。对于该应用程序,我们使用了付费 SSL 证书。该证书的到期日期为 2021 年 6 月。但是今天,我们遇到了一个错误-

cURL error 60: SSL certificate problem: certificate has expired (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)

我们检查证书到期日期,但没有问题(2021 年 6 月)。然后我们关注这个帖子 - curl: (60) SSL certificate problem: unable to get local issuer certificate(@Dahomz 回答)

之后,当我们通过 - curl -v --url https://backend.abc.com --cacert /etc/ssl/ssl.cert/cacert.pem 卷曲 abc.com 时,它工作正常。回复喜欢 -

* Rebuilt URL to: https://backend.abc.com/
*   Trying 127.0.0.1...
* Connected to backend.abc.com (127.0.0.1) port 443 (#0)
* found 139 certificates in /etc/ssl/ssl.cert/cacert.pem
* found 600 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ******_RSA_***_***_GCM_*****
*    server certificate verification OK
*    server certificate status verification SKIPPED
*    common name: *.abc.com (matched)
*    server certificate expiration date OK
*    server certificate activation date OK
*    certificate public key: RSA
*    certificate version: #3
*    subject: OU=Domain Control Validated,OU=PositiveSSL Wildcard,CN=*.abc.xyz
*    start date: Mon, 04 May 2019 00:00:00 GMT
*    expire date: Wed, 07 June 2021 23:59:59 GMT
*    issuer: C=GB,ST=Greater Manchester,L=Salford,O=Sectigo Limited,CN=Sectigo RSA Domain Validation Secure Server CA
*    compression: NULL
* ALPN, server accepted to use http/1.1

但是当我们通过 curl 从 frontend.abc.com 到 backend.abc.com 时,它会抛出这个错误 -

* Rebuilt URL to: https://backend.abc.com/
*   Trying 127.0.0.1...
* Connected to backend.abc.com (127.0.0.1) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/ssl.cert/cacert.pem
  CApath: /etc/ssl/certs
* SSL connection using TLSv1.2 / *****-RSA-*****-GCM-******
* ALPN, server accepted to use http/1.1
* Server certificate:
*    subject: OU=Domain Control Validated; OU=PositiveSSL Wildcard; CN=*.abc.com
*    start date: Mar  4 00:00:00 2019 GMT
*    expire date: Apr  7 23:59:59 2021 GMT
*    issuer: C=GB; ST=Greater Manchester; L=Salford; O=Sectigo Limited; CN=Sectigo RSA Domain Validation Secure Server CA
*    SSL certificate verify result: certificate has expired (10), continuing anyway.

我的 curl 代码 -

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://backend.abc.com");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_STDERR, fopen(public_path("c.log"), 'w'));
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$output = curl_exec($ch);
$error = curl_error($ch);
$info = curl_getinfo($ch);
curl_close($ch);

【问题讨论】:

  • 检查整个链条而不仅仅是叶子。 Sectigo-was-Comodo,在根存储接受 USERTrust 根之前,也从 AddTrust 链接,并且如果您在“后端”上的 curl 仍在使用已过期的 AddTrust 链。见support.sectigo.com/Com_KnowledgeDetailPage?Id=kA03l00000117LT
  • 你能给我们任何提示如何解决这个问题吗?

标签: ssl curl


【解决方案1】:

如果您在 Ubuntu 16 系统上遇到“curl”(或类似问题)问题,我们将按照以下方法解决:

在托管失败的 curl / 应用程序的 Ubuntu 16 系统上:

  • 纳米 /etc/ca-certificates.conf
  • 删除指定 AddTrust_External_Root.crt 的行(或注释)
  • apt update && apt install ca-certificates
  • update-ca-certificates -f -v
  • 使用之前失败的 URL 再次尝试 curl - 希望它现在可以工作 :)

【讨论】:

  • 它不工作。当我们通过 curl 从 frontend.abc.com 到 backend.abc.com 时,它显示相同的错误。
  • @HasanHafizPasha 你有 curl 的问题吗(就像我的帖子中提到的那样)?
  • 是的@mrmuggles,来自前端应用程序的 curl 调用
  • 好吧,如果您使用的是 Ubuntu 16,它应该可以工作。您在运行上述程序时是否收到任何错误消息?此外,如果您可以访问后端,@Manu 的答案会更好,因为您将“修复”源代码。
  • 我很确定并感谢您解决了我的问题,但是在我的 Debian 系统上,我认为 sudo dpkg-reconfigure ca-certificates 可能是“nano /etc/ca-certificates.conf”的推荐方式取消选择 AddTrust_External_Root,以确保将文件保持为工具可以理解的格式。
【解决方案2】:

要解决此问题,请从您的域证书中删除过期的根证书。

  1. 转到https://whatsmychaincert.com
  2. 测试您的服务器
  3. 如果他们确认您的根证书已过期,请下载并使用没有此证书的 .crt。

【讨论】:

  • 谢谢。我建议编辑您的答案以首先进行完整修复,因为真正设置 curl 选项并不是一个修复,因为访问相同证书的其他(旧)客户端仍然存在该问题。 whatsmychaincert.com 网站非常适合诊断此问题 - 谢谢!
  • 我同意@BlueC:证书修复应该首先突出显示,然后为 OP 添加临时 curl 修复
  • 这些步骤解决了服务器端的问题。请注意,您将在第 3 步下载的证书将用于代替旧的 CA 证书。
  • 我应该在哪里输入这些命令?...在​​哪个文件中?
  • 请勿使用 SSL_VERIFYPEER = 0,这会打开您对中间人攻击的请求。这不是一个解决方案,只是一个临时测试,绝不应该在生产中使用!
【解决方案3】:

您的信任库似乎没有使用最新的受信任根进行更新。了解它从昨天 5 月 30 日开始发生在你身上。我假设您将 Sectigo 作为您的 CA。

更新您的信任,您应该能够连接。

https://support.sectigo.com/articles/Knowledge/Sectigo-AddTrust-External-CA-Root-Expiring-May-30-2020

【讨论】:

    【解决方案4】:

    永久的解决方案是从您的提供商处重新颁发 SSL 证书并将其重新安装到您的服务器上。

    重新颁发的证书将更新 CA 包。

    干杯!

    【讨论】:

      【解决方案5】:

      我们有同样的错误。为了解决您的问题,请使用您受信任的 SSL 站点的最新版本更新您的“SSLCertificateChainFile”。在我们的例子中是 comodo。

      您需要访问您信任的站点并在您的证书下找到“CA-CRT”。复制内容。

      1. 转到您的 /etc/apache2/sites-available
      2. 找到带有“SSLCertificateChainFile”的行。
      3. 接下来编辑文件并将内容替换为新的 CA-CRT 值。
      4. 然后重新启动您的 Web 服务器,在我们的例子中是 apache: 服务 apache2 重启 要么 systemctl 重启 apache2

      如果您无法重新启动 apache,简单的方法是重新启动您的实例。

      【讨论】:

        【解决方案6】:

        对于 ubuntu 14.04

        打开你的终端

        sudo su
        wget https://support.sectigo.com/Com_KnowledgeDetailPage?Id=kA01N000000rfBO -O SHA-2_Root_USERTrust_RSA_Certification_Authority.crt --no-check-certificate
        cp SHA-2_Root_USERTrust_RSA_Certification_Authority.crt /usr/share/ca-certificates/mozilla/
        

        然后 dpkg-reconfigure ca-certificates取消选中 mozilla/AddTrust_External_Root.crt 并选中 mozilla/2_Root_USERTrust_RSA_Certification_Authority.crt
        或运行sudo update-ca-certificates 取消选中这些。

        【讨论】:

        • 今天DST_Root_CA_X3.crt 证书已过期,Let's Encrypt 证书无效。要修复它,只需使用 sudo dpkg-reconfigure ca-certificates 工具停用证书即可。
        • 谢谢。我已经尝试解决此问题 5 天了!
        • Grazie mille caro :-),您的提示结束了为期两天的噩梦。只是一个让我有点犹豫的小补充:在 dpgk-reconfigure 的第一个屏幕中......正确的答案是“询问”,然后会显示可用证书的列表。滚动到 DST_Root_CA_X3.crt,取消选中并按 Tab 键选择“确定”。
        【解决方案7】:

        我们遇到了同样的问题,经过一些故障排除后,我们发现 COMODO 的根证书已过期。

        Valid until Sat, 30 May 2020 10:48:38 UTC (expired 3 days, 5 hours ago) EXPIRED

        我们通过以下方式对此进行了测试:https://www.ssllabs.com/ssltest/index.html。 我们通过从经销商处下载新证书解决了这个问题。

        This is the result we received about the COMODO certificates

        【讨论】:

          【解决方案8】:

          我必须在基于 debian 的服务器上解决此问题

          这是由于系统使用了openssl(curl依赖于openssl)

          事情是这样的:

          1. 从您的系统中删除 AddTrust_External_Root.crt(通常在 /etc/ssl/certs 中找到)
            1. /etc/ca-certificates.conf 中删除或注释“mozilla/AddTrust_External_Root”行
            2. 运行sudo update-ca-certificates更新openssl使用的证书

          也许对你有帮助?

          【讨论】:

            【解决方案9】:

            昨天我遇到了@finesse 上面报告的问题。由于在我们的系统上 ca-certificates 会自动更新,所以我很困扰,因为证书是有效的

            • 在命令行中使用 curl
            • 在 php-cli 中使用 php 脚本

            但它在网站上不起作用。

            解决方案很简单:

            只需重启 php-fpm :/

            最好的问候,

            威利

            【讨论】:

              【解决方案10】:

              您可以启用insecure 连接,将此选项添加到您的 $HOME/.curlrc文件:

              $ echo "insecure" >> ~/.curlrc

              不建议永久保留它,但是,对于快速和临时的解决方案,这是一个不错的选择。

              参考:How to apply the changes for all HTTPS connection

              【讨论】:

              猜你喜欢
              • 1970-01-01
              • 2021-11-23
              • 2014-02-06
              • 2020-09-20
              • 2021-12-14
              • 2021-11-26
              • 2017-11-21
              • 2021-06-02
              • 2019-12-11
              相关资源
              最近更新 更多