Skip to content

Commit 0d2e2e5

Browse files
authored
Reload certificates even when no CA is used (#707)
This commit uses the roundtripper that reloads itself even when there is no CA, so when keys and certs are reloaded on disk, we have a new rountripper and we use the new certificates. Signed-off-by: Julien <[email protected]>
1 parent a9d2e3f commit 0d2e2e5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

config/http_config.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,8 +679,8 @@ func NewRoundTripperFromConfigWithContext(ctx context.Context, cfg HTTPClientCon
679679
if err != nil {
680680
return nil, err
681681
}
682-
if tlsSettings.CA == nil || tlsSettings.CA.Immutable() {
683-
// No need for a RoundTripper that reloads the CA file automatically.
682+
if tlsSettings.immutable() {
683+
// No need for a RoundTripper that reloads the files automatically.
684684
return newRT(tlsConfig)
685685
}
686686
return NewTLSRoundTripperWithContext(ctx, tlsConfig, tlsSettings, newRT)
@@ -914,7 +914,7 @@ func (rt *oauth2RoundTripper) newOauth2TokenSource(req *http.Request, secret str
914914
if err != nil {
915915
return nil, nil, err
916916
}
917-
if tlsSettings.CA == nil || tlsSettings.CA.Immutable() {
917+
if tlsSettings.immutable() {
918918
t, _ = tlsTransport(tlsConfig)
919919
} else {
920920
t, err = NewTLSRoundTripperWithContext(req.Context(), tlsConfig, tlsSettings, tlsTransport)
@@ -1259,6 +1259,10 @@ type TLSRoundTripperSettings struct {
12591259
Key SecretReader
12601260
}
12611261

1262+
func (t *TLSRoundTripperSettings) immutable() bool {
1263+
return (t.CA == nil || t.CA.Immutable()) && (t.Cert == nil || t.Cert.Immutable()) && (t.Key == nil || t.Key.Immutable())
1264+
}
1265+
12621266
func NewTLSRoundTripper(
12631267
cfg *tls.Config,
12641268
settings TLSRoundTripperSettings,

0 commit comments

Comments
 (0)