簡體   English   中英

cURL 錯誤60:SSL 證書問題:證書已過期

[英]cURL error 60: SSL certificate problem: certificate has expired

我們在亞馬遜 EC2 上運行 2 個應用程序( backend.example.comfrontend.example.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 證書問題:無法獲得本地頒發者證書(@Dahomz 回答)

After that, when we curl example.com by - curl -v --url https://backend.example.com --cacert /etc/ssl/ssl.cert/cacert.pem , It working fine. 回應如 -

* Rebuilt URL to: https://backend.example.com/
*   Trying 127.0.0.1...
* Connected to backend.example.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: *.example.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=*.example.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.example.combackend.example.com時,它會拋出這個錯誤 -

* Rebuilt URL to: https://backend.example.com/
*   Trying 127.0.0.1...
* Connected to backend.example.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=*.example.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.example.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);

要解決此問題,請從您的域證書中刪除過期的根證書。

  1. Go 到https://whatsmychaincert.com
  2. 測試你的服務器
  3. 如果他們確認您的根證書已過期,請下載並使用沒有此證書的.crt。

如果您在 Ubuntu 16 系統上遇到“卷曲”(或類似問題)問題,以下是我們修復它的方法:

在 Ubuntu 16 系統托管 curl / 應用程序失敗:

  • 納米 /etc/ca-certificates.conf
  • 刪除指定 AddTrust_External_Root.crt 的行(或注釋)
  • apt update && apt install ca-certificates
  • 更新 CA 證書 -f -v
  • 使用之前失敗的 URL 再次嘗試 curl - 希望它現在可以工作:)

對於 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取消選中這些。

您可以啟用insecure連接,將此選項添加到您的$HOME/.curlrc文件:

$ echo "insecure" >> ~/.curlrc

不建議永久保留它,但是,對於快速和臨時的解決方案,這是一個不錯的選擇。

參考: 如何應用所有 HTTPS 連接的更改

您的信任庫似乎未使用最新的受信任根更新。 了解它從昨天 5 月 30 日開始發生在你身上。 我假設您將 Sectigo 作為您的 CA。

更新您的信任,您應該能夠連接。

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

昨天我遇到了@finesse 上面報告的問題。 由於在我們的系統上,ca-certificates 會自動更新,因此我很困擾,因為證書是有效的

  • 在命令行上使用 curl
  • 使用帶有 php-cli 的 php 腳本

但它在 web 站點上不起作用。

解決方案很簡單:

只需重新啟動 php-fpm:/

此致,

威利

永久的解決方案是從您的提供商重新頒發 SSL 證書並將其重新安裝到您的服務器上。

重新頒發的證書將更新 CA 包。

干杯!

我們有同樣的錯誤。 為了解決您的問題,請使用您信任的 SSL 站點的最新版本更新您的“SSLCertificateChainFile”。 在我們的例子中是comodo。

您需要 go 到您信任的站點,並在您的證書下找到“CA-CRT”。 復制內容。

  1. Go 到您的 /etc/apache2/sites-available
  2. 找到帶有“SSLCertificateChainFile”的行。
  3. 接下來編輯文件並將內容替換為新的 CA-CRT 值。
  4. 然后重啟你的 web 服務器,在我們的例子中是 apache: service apache2 restart or systemctl restart Z974318ED5C13640BFBCC536

如果您無法重啟 apache,簡單的方法是重啟您的實例。

我們遇到了同樣的問題,經過一些故障排除后,我們發現 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 我們通過從經銷商處下載新證書解決了這個問題。

這是我們收到的關於 COMODO 證書的結果

我必須在基於 debian 的服務器上解決此問題

這是由於系統使用了 openssl(卷曲取決於 openssl)

這是怎么回事:

  1. 從系統中刪除 AddTrust_External_Root.crt(通常在/etc/ssl/certs中找到)
    1. /etc/ca-certificates.conf中刪除或注釋“mozilla/AddTrust_External_Root”行
    2. 運行sudo update-ca-certificates更新 openssl 使用的證書

也許它可以幫助你?

更改或編輯以下設置:

從客戶域 SSL 中的服務器更改這些文件

服務器密鑰= 服務器密鑰是服務器使用的私有加密/解密密鑰。

中間證書 (CA) = 證書頒發機構 (CA) 是頒發數字證書的實體,該證書將通過證書的命名主體驗證公鑰的所有權。

域證書= 域證書是由證書頒發機構提供的電子文檔,用於檢查申請人使用特定域名的許可。

我設法通過在我的服務器上運行更新來解決問題:

sudo yum update

這似乎解決了 curl 證書的任何問題。

sudo update-ca-certificates

修復了我的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM