golang https server客户端不进行验证
x509 相关的错误返回,说客户段程序还是验证了服务器的
`import (
"crypto/tls"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{Transport: tr}
resp, err := client.Get("https://localhost:8081")
if err != nil {
fmt.Println("error:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}`
本文来自博客园,作者:ljymoonlight,转载请注明原文链接:https://www.cnblogs.com/ljymoonlight/p/16074644.html
posted on 2022-03-30 00:44 ljymoonlight 阅读(148) 评论(0) 编辑 收藏 举报