代码请求地址时出现一下报错. 看的出来是这个站点证书的问题
[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