Centos

Curl、lynx 等不接受本地證書但遠端 OK

  • December 20, 2018

當我連接到我的 Web 伺服器以通過 HTTPS 查看站點時,我在地址欄中看到了漂亮的綠色 EV 東西。當我在本地使用 curl 進行連接時,它會抱怨證書並死掉。

我知道我可以跳過證書檢查,但我想解決這個問題,因為有時會在本地檢查這些證書。

我的主機文件(在伺服器上)將 www.domain.com 映射到 192.168.100.62。Apache 正在監聽哪個(通過通過 http 對同一地址執行 cURL 確認):

root@web3:~# curl -v https://www.domain.com
* About to connect() to www.domain.com port 443 (#0)
*   Trying 192.168.100.62... connected
* Connected to www.domain.com (192.168.100.62) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt
 CApath: none
* Peer's certificate issuer is not recognized: 'CN=Symantec Class 3 EV SSL CA - G3,OU=Symantec Trust Network,O=Symantec Corporation,C=US'
* NSS error -8179
* Closing connection #0
* Peer certificate cannot be authenticated with known CA certificates
curl: (60) Peer certificate cannot be authenticated with known CA certificates
More details here: http://curl.haxx.se/docs/sslcerts.html

我在 google 上翻了一下,但似乎找不到太多。我的根 CA 包可能已過時,或者 curl 本身太舊而無法連接,但我對此沒有太多經驗。

root@web3:~# curl --version
curl 7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.18 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps scp sftp
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

cat /etc/redhat-release Red Hat Enterprise Linux Server 6.7 版(聖地亞哥)

我曾嘗試使用該update-ca-trust工具添加威瑞信根證書,但這也沒有影響:

root@web3:anchors# pwd
/etc/pki/ca-trust/source/anchors
root@web3:anchors# ls
VeriSign-Class-3-Public-Primary-Certification-Authority-G3.crt
root@web3:anchors#  update-ca-trust
root@web3:anchors# curl... <snip> same error.

對於實際問題是什麼,我有點茫然。證書是否僅在網際網路 IP 上有效?

已編輯(2018-12-20):安全警告:安裝來自未知來源的證書存在安全風險。

我通過下載 Symantec_Class_3_EV_SSL_CA_G3.crt 並安裝它解決了這個問題:

wget http://symantec.tbs-certificats.com/Symantec_Class_3_EV_SSL_CA_G3.crt
cp Symantec_Class_3_EV_SSL_CA_G3.crt /etc/pki/ca-trust/source/anchors
update-ca-trust

然後問題就消失了 :) 不知道為什麼預設情況下它不包含在根 CA 捆綁包中。

引用自:https://serverfault.com/questions/713116