【问题标题】:How to fix TLS error on www.fedex.com when using uTls?使用 uTls 时如何修复 www.fedex.com 上的 TLS 错误?
【发布时间】:2020-12-30 08:14:27
【问题描述】:

有人可以帮助我在 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
}

【问题讨论】:

    标签: go go-http


    【解决方案1】:
                tlsConn.SetSNI(URL)
    

    SNI 的值应该是主机名 (www.fedex.com) 而不是 URL (https://www.fedex.com)。这有效:

                u,_ := url.Parse(URL)
                tlsConn.SetSNI(u.Host)
    

    【讨论】:

    • 嘿,没用。我得到Get "www.fedex.com": unsupported protocol scheme ""
    • @jjboi8708:完全对我发布的代码所做的更改对我有用。与此相比,我不知道你做了什么。但也许您刚刚将 URL 从https://www.fedex.com 设置为www.fedex.com?这不起作用,因为 URL 也用于NewRequest,其中https://... 很重要。
    • 哦,nvm 成功了。是的,你是对的,我用 NewRequest 中解析的 URL 更改了 URL。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-05-29
    • 1970-01-01
    • 2022-12-13
    • 2022-01-24
    • 1970-01-01
    • 2021-12-31
    • 2021-11-17
    相关资源
    最近更新 更多