有人可以幫助我在 go 中使用 uTls 修復我的 TLS 嗎?每當我嘗試對https://www.fedex.com/的 GET 請求時,我都會得到:Get "https://www.fedex.com/": uTlsConn.Handshake() error: remote error: tls: internal error這是我的代碼:func tls_connection(URL string) *http.Response { cookieJar, _ := cookiejar.New(nil) client := &http.Client{ Jar: cookieJar} tlsConn.SetSNI(URL) req, err := http.NewRequest("GET", URL, nil) req.Header.Add("user-agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36") // the client.do wraps the request resp, err := client.Do(req) if err != nil { fmt.Println(err) } else { fmt.Println(resp.StatusCode) body, _ := ioutil.ReadAll(resp.Body) fmt.Println(string(body)) } return resp}
1 回答
慕沐林林
TA貢獻2016條經驗 獲得超9個贊
tlsConn.SetSNI(URL)
SNI 的值應該是主機名 ( www.fedex.com) 而不是 URL ( https://www.fedex.com)。這有效:
u,_ := url.Parse(URL) tlsConn.SetSNI(u.Host)
- 1 回答
- 0 關注
- 158 瀏覽
添加回答
舉報
0/150
提交
取消
