File tree 1 file changed +11
-4
lines changed
1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -73,11 +73,22 @@ func NewTLSConfigPool(ctx context.Context) TLSConfigPool {
73
73
74
74
// LoadTLSConfig loads a TLS configuration from the given TLSConfig.
75
75
func (p * tlsConfigPool ) LoadTLSConfig (config TLSConfig ) (* tls.Config , error ) {
76
+ if config .GetTrustedCertificateAuthority () == "" &&
77
+ config .GetTrustedCertificateAuthorityFile () == "" &&
78
+ config .GetSkipVerifyPeerCert () == nil {
79
+ // no given TLS config, nothing to load
80
+ return nil , nil
81
+ }
82
+
76
83
encConfig := encodeConfig (config )
77
84
id := encConfig .hash ()
85
+
86
+ p .mu .Lock ()
78
87
if tlsConfig , ok := p .configs [id ]; ok {
88
+ p .mu .Unlock ()
79
89
return tlsConfig , nil
80
90
}
91
+ p .mu .Unlock ()
81
92
82
93
log := p .log .With ("id" , id )
83
94
log .Info ("loading new TLS config" , "config" , encConfig .JSON ())
@@ -102,10 +113,6 @@ func (p *tlsConfigPool) LoadTLSConfig(config TLSConfig) (*tls.Config, error) {
102
113
103
114
case config .GetSkipVerifyPeerCert () != nil :
104
115
tlsConfig .InsecureSkipVerify = BoolStrValue (config .GetSkipVerifyPeerCert ())
105
-
106
- default :
107
- // No CA or skip verification, return nil TLS config
108
- return nil , nil
109
116
}
110
117
111
118
// Add the loaded CA to the TLS config
You can’t perform that action at this time.
0 commit comments