File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -528,11 +528,7 @@ func parseDSNParams(cfg *Config, params string) (err error) {
528
528
return fmt .Errorf ("invalid value for TLS config name: %v" , err )
529
529
}
530
530
531
- tlsConfigLock .RLock ()
532
- if tlsConfig , ok := tlsConfigRegister [name ]; ok {
533
- tlsConfig = cloneTLSConfig (tlsConfig )
534
- tlsConfigLock .RUnlock ()
535
-
531
+ if tlsConfig := getTLSConfigClone (name ); tlsConfig != nil {
536
532
if len (tlsConfig .ServerName ) == 0 && ! tlsConfig .InsecureSkipVerify {
537
533
host , _ , err := net .SplitHostPort (cfg .Addr )
538
534
if err == nil {
@@ -543,7 +539,6 @@ func parseDSNParams(cfg *Config, params string) (err error) {
543
539
cfg .TLSConfig = name
544
540
cfg .tls = tlsConfig
545
541
} else {
546
- tlsConfigLock .RUnlock ()
547
542
return errors .New ("invalid value / unknown config name: " + name )
548
543
}
549
544
}
Original file line number Diff line number Diff line change @@ -74,6 +74,15 @@ func DeregisterTLSConfig(key string) {
74
74
tlsConfigLock .Unlock ()
75
75
}
76
76
77
+ func getTLSConfigClone (key string ) (config * tls.Config ) {
78
+ tlsConfigLock .RLock ()
79
+ if v , ok := tlsConfigRegister [key ]; ok {
80
+ config = cloneTLSConfig (v )
81
+ }
82
+ tlsConfigLock .RUnlock ()
83
+ return
84
+ }
85
+
77
86
// Returns the bool value of the input.
78
87
// The 2nd return value indicates if the input was a valid bool value
79
88
func readBool (input string ) (value bool , valid bool ) {
You can’t perform that action at this time.
0 commit comments