ljymoonlight

导航

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))

}`

posted on 2022-03-30 00:44  ljymoonlight  阅读(148)  评论(0编辑  收藏  举报