代碼請求地址時出現一下報錯. 看的出來是這個站點證書的問題php
[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]html
goroutine 1 [running]:
main.PostWebService(0x6a1729, 0x38, 0xc0000f4040, 0x3c, 0x0, 0x0, 0x0, 0x0)
/home/zhangxg/work/test/httpClient.go:16 +0x17bdom
main.main()curl
/home/zhangxg/work/test/httpClient.go:40 +0x193this
用curl命令來一下... # 忽略證書檢查 curl -kurl
[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.htmlspa
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..net
這種狀況, 證書的問題, 若是是自家站點, 那就從簽發證書的代理商那要一下中級受權證書,合成一下基本就ok了. 順序爲: 由低到高代理
證書相關連接code
若是不是自家站點, 那就須要從代碼裏添加忽略證書檢查的操做了.
https://www.cnblogs.com/mingetty/p/11024243.html