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) {
528528 return fmt .Errorf ("invalid value for TLS config name: %v" , err )
529529 }
530530
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 {
536532 if len (tlsConfig .ServerName ) == 0 && ! tlsConfig .InsecureSkipVerify {
537533 host , _ , err := net .SplitHostPort (cfg .Addr )
538534 if err == nil {
@@ -543,7 +539,6 @@ func parseDSNParams(cfg *Config, params string) (err error) {
543539 cfg .TLSConfig = name
544540 cfg .tls = tlsConfig
545541 } else {
546- tlsConfigLock .RUnlock ()
547542 return errors .New ("invalid value / unknown config name: " + name )
548543 }
549544 }
Original file line number Diff line number Diff line change @@ -74,6 +74,15 @@ func DeregisterTLSConfig(key string) {
7474 tlsConfigLock .Unlock ()
7575}
7676
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+
7786// Returns the bool value of the input.
7887// The 2nd return value indicates if the input was a valid bool value
7988func readBool (input string ) (value bool , valid bool ) {
You can’t perform that action at this time.
0 commit comments