$ openssl genrsa -out server.key 2048 // private key  
$ openssl req -new -x509 -key server.key -out server.crt -days 365 //self-signed certificate  

//省略证书校验(一般用于测试)

tr := &http.Transport{  
   TLSClientConfig: &tls.Config{InsecureSkipVerify: true},  
}  

client := &http.Client{Transport: tr}  
resp, err := client.Get("https://localhost:8081")  

可以使用openssl x509 -text -in client.crt -noout 查看某个证书文件所包含的具体信息。

资料1

资料2

gthub代码示例:



blog comments powered by Disqus

Published

2016-02-25

Categories


Tags