I create a http client and make a http request with an attached (self-signed) cert object. I add InsecureSkipVerify: true
to the client's TLSClientConfig
to avoid errors.
Later I make another, unrelated request without a cert, which fails due to
x509: certificate signed by unknown authority
This goes away if I add InsecureSkipVerify: true
to the new request, but I feel like I shouldn't have to because the second request has nothing to do with any kind of certification.
Can anyone tell me why the second, un-certified request might be throwing this error? I tried transport.CloseIdleConnections()
after the first request finished, but that seemed to do no good.
first request:
func (s *loginSession) loginRequest() ([]byte, error) {
cert, err := tls.LoadX509KeyPair(
assist.PathToPackage()+certFilePath,
assist.PathToPackage()+keyFilePath,
)
if err != nil {
return nil, err
}
trans := &http.Transport{
DisableKeepAlives: true,
TLSClientConfig: &tls.Config{
Certificates: []tls.Certificate{cert},
InsecureSkipVerify: true,
},
}
client := &http.Client{
Transport: trans,
}
req, err := http.NewRequest("POST", loginURL, s.loginPayload())
if err != nil {
return nil, err
}
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
req.Header.Add("X-Application", s.applicationKey)
resp, err := client.Do(req)
if err != nil {
return nil, err
}
bodyBytes, err := assist.SafeJsonBytes(resp.Body)
trans.CloseIdleConnections()
return bodyBytes, err
}
Is there any reason why subsequent requests with different clients might contain the same cert for some reason?