golang http自动转为https 如何跳过证书检查

 func SendReq(req *http.Request,result interface{}) error {
	tr := &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	}
	client := &http.Client{Transport:tr}
	resp,err := client.Do(req)
	if err != nil{
		fmt.Printf("Fail exec http client Do,err:%s\n",err.Error())
		return err
	}
    ...
}

关键是在上面代码中 tr 变量中将 tls.Config 给跳过

posted @ 2018-09-21 17:42  灰天使  阅读(2735)  评论(0编辑  收藏  举报