Skip to content

Commit

Permalink
Revert "Only create new client if ca file changed"
Browse files Browse the repository at this point in the history
This reverts commit c63387b.
  • Loading branch information
LeviHarrison committed Nov 30, 2021
1 parent c63387b commit de05404
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions config/http_config.go
Expand Up @@ -847,30 +847,27 @@ func (t *tlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
}

t.mtx.RLock()
caEqual := bytes.Equal(caHash[:], t.hashCAFile)
certKeyEqual := bytes.Equal(certHash[:], t.hashCertFile) && bytes.Equal(keyHash[:], t.hashKeyFile)
equal := bytes.Equal(caHash[:], t.hashCAFile) &&
bytes.Equal(certHash[:], t.hashCertFile) &&
bytes.Equal(keyHash[:], t.hashKeyFile)
rt := t.rt
t.mtx.RUnlock()
if caEqual && certKeyEqual {
if equal {
// The CA cert hasn't changed, use the existing RoundTripper.
return rt.RoundTrip(req)
}

// Create a new RoundTripper.
// The cert and key files are read separately by the client
// using GetClientCertificate, therefore the RoundTripper
// doesn't need to be updated if only they are changed.
if !caEqual {
// Create a new RoundTripper.
tlsConfig := t.tlsConfig.Clone()
if !updateRootCA(tlsConfig, caData) {
return nil, fmt.Errorf("unable to use specified CA cert %s", t.caFile)
}
rt, err = t.newRT(tlsConfig)
if err != nil {
return nil, err
}
// using GetClientCertificate.
tlsConfig := t.tlsConfig.Clone()
if !updateRootCA(tlsConfig, caData) {
return nil, fmt.Errorf("unable to use specified CA cert %s", t.caFile)
}
rt, err = t.newRT(tlsConfig)
if err != nil {
return nil, err
}

t.CloseIdleConnections()

t.mtx.Lock()
Expand Down

0 comments on commit de05404

Please sign in to comment.