Skip to content

Commit 102c12a

Browse files
committed
Revert "Only create new client if ca file changed"
This reverts commit c63387b. Signed-off-by: Levi Harrison <git@leviharrison.dev>
1 parent c63387b commit 102c12a

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

config/http_config.go

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -847,30 +847,27 @@ func (t *tlsRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
847847
}
848848

849849
t.mtx.RLock()
850-
caEqual := bytes.Equal(caHash[:], t.hashCAFile)
851-
certKeyEqual := bytes.Equal(certHash[:], t.hashCertFile) && bytes.Equal(keyHash[:], t.hashKeyFile)
850+
equal := bytes.Equal(caHash[:], t.hashCAFile) &&
851+
bytes.Equal(certHash[:], t.hashCertFile) &&
852+
bytes.Equal(keyHash[:], t.hashKeyFile)
852853
rt := t.rt
853854
t.mtx.RUnlock()
854-
if caEqual && certKeyEqual {
855+
if equal {
855856
// The CA cert hasn't changed, use the existing RoundTripper.
856857
return rt.RoundTrip(req)
857858
}
858859

860+
// Create a new RoundTripper.
859861
// The cert and key files are read separately by the client
860-
// using GetClientCertificate, therefore the RoundTripper
861-
// doesn't need to be updated if only they are changed.
862-
if !caEqual {
863-
// Create a new RoundTripper.
864-
tlsConfig := t.tlsConfig.Clone()
865-
if !updateRootCA(tlsConfig, caData) {
866-
return nil, fmt.Errorf("unable to use specified CA cert %s", t.caFile)
867-
}
868-
rt, err = t.newRT(tlsConfig)
869-
if err != nil {
870-
return nil, err
871-
}
862+
// using GetClientCertificate.
863+
tlsConfig := t.tlsConfig.Clone()
864+
if !updateRootCA(tlsConfig, caData) {
865+
return nil, fmt.Errorf("unable to use specified CA cert %s", t.caFile)
866+
}
867+
rt, err = t.newRT(tlsConfig)
868+
if err != nil {
869+
return nil, err
872870
}
873-
874871
t.CloseIdleConnections()
875872

876873
t.mtx.Lock()

0 commit comments

Comments
 (0)