Search code examples
gogo-http

How to fix TLS error on www.fedex.com when using uTls?


Can someone help me with fixing my TLS using uTls in go? Whenever I try a GET request for https://www.fedex.com/ I get:

Get "https://www.fedex.com/": uTlsConn.Handshake() error: remote error: tls: internal error

Here is my code:

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
}

Solution

  •             tlsConn.SetSNI(URL)
    

    The value for SNI should be the hostname (www.fedex.com) and not the URL (https://www.fedex.com). This works:

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