curl https時報錯 curl: (60) Peer certificate cannot be authenticated with known CA certificates


代碼請求地址時出現一下報錯. 看的出來是這個站點證書的問題

[root@local test]# ./httpClient
Post https://smartclass.xxx.com/interface/EduInterface.php: x509: certificate signed by unknown authority
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x60cafb]

goroutine 1 [running]:
main.PostWebService(0x6a1729, 0x38, 0xc0000f4040, 0x3c, 0x0, 0x0, 0x0, 0x0)
/home/zhangxg/work/test/httpClient.go:16 +0x17b

main.main()

/home/zhangxg/work/test/httpClient.go:40 +0x193

用curl命令來一下...    # 忽略證書檢查 curl -k

[root@local ~]# curl https://smartclass.xxx.com/interface/EduInterface.php
curl: (60) Peer certificate cannot be authenticated with known CA certificates
More details here: http://curl.haxx.se/docs/sslcerts.html

curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.

 

這種情況, 證書的問題, 如果是自家站點, 那就從簽發證書的代理商那要一下中級授權證書,合成一下基本就ok了. 順序為: 由低到高

證書相關鏈接

如果不是自家站點, 那就需要從代碼里添加忽略證書檢查的操作了.

https://www.cnblogs.com/mingetty/p/11024243.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM