gojek / heimdall

An enhanced HTTP client for Go
http://gojek.tech
Apache License 2.0
2.61k stars 215 forks source link

How can I set verify=false when call to HTTPS endpoint? #103

Closed iamatsundere closed 3 years ago

iamatsundere commented 3 years ago

Hi, I just want to set InsecureSkipVerify = true, how can I do that. Be cause when I make a call to this address, the return is responed like this:

Post "https://my-uri.com": x509: certificate is not valid for any names, but wanted to match my-uri.com

iamatsundere commented 3 years ago

Okay, my solution is

tr := http.DefaultTransport.(*http.Transport)
    tr.TLSClientConfig.InsecureSkipVerify = true
    client := &http.Client{Transport: tr}

    httpClient := httpclient.NewClient(
        httpclient.WithHTTPClient(client),
        httpclient.WithHTTPTimeout(timeout),
        httpclient.WithRetryCount(3),
    )
mannharleen commented 2 years ago

And this was mine: (pretty similar) -

tr := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
client := &http.Client{Transport: tr}

httpClient := httpclient.NewClient(
  httpclient.WithHTTPClient(client),
  httpclient.WithHTTPTimeout(timeout),
  httpclient.WithRetryCount(retryCount),
)
res, err := httpClient.Get(conf.HTTPRequestConfig.URL, nil)