cURL错误60:SSL证书问题:证书已过期

时间:2020-05-30 19:07:08

标签: ssl curl

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

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

我们检查证书的到期日期,但是没有问题( 2021年6月)。然后,我们遵循此线程-read JulianBauer's answer here(@ 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.

我的卷曲代码-

$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);

8 个答案:

答案 0 :(得分:32)

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

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

(可选),在执行此操作时,可以使用此临时curl修复程序,以确保网站上没有错误: 添加此选项:

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);

答案 1 :(得分:13)

如果您在Ubuntu 16系统上遇到“卷曲”(或类似问题)的问题,我们可以通过以下方法对其进行修复:

在托管curl / app失败的Ubuntu 16系统上:

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

答案 2 :(得分: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取消选中它们。

答案 3 :(得分:3)

似乎您的信任库未使用最新的受信任根进行更新。自从5月30日昨天开始,您就知道这件事发生了。我假设您拥有Sectigo作为您的CA。

更新您的托管人,您应该可以连接。

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

答案 4 :(得分:1)

一种永久性的解决方案是从提供商处重新颁发SSL证书,然后将其重新安装在服务器上。

重新颁发的证书将更新CA捆绑软件。

干杯!

答案 5 :(得分:1)

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

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

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

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

答案 6 :(得分:1)

我们遇到了同样的问题,经过一些故障排除后,我们发现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

答案 7 :(得分:1)

我必须在基于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使用的证书

也许可以帮助您?