@@ -20,15 +20,17 @@ import (
2020 "time"
2121)
2222
23+ // Registry for custom tls.Configs
2324var (
2425 tlsConfigLock sync.RWMutex
25- tlsConfigRegister map [string ]* tls.Config // Register for custom tls.Configs
26+ tlsConfigRegistry map [string ]* tls.Config
2627)
2728
2829// RegisterTLSConfig registers a custom tls.Config to be used with sql.Open.
2930// Use the key as a value in the DSN where tls=value.
3031//
31- // Note: The tls.Config provided to needs to be exclusively owned by the driver after registering.
32+ // Note: The provided tls.Config is exclusively owned by the driver after
33+ // registering it.
3234//
3335// rootCertPool := x509.NewCertPool()
3436// pem, err := ioutil.ReadFile("/path/ca-cert.pem")
@@ -56,27 +58,27 @@ func RegisterTLSConfig(key string, config *tls.Config) error {
5658 }
5759
5860 tlsConfigLock .Lock ()
59- if tlsConfigRegister == nil {
60- tlsConfigRegister = make (map [string ]* tls.Config )
61+ if tlsConfigRegistry == nil {
62+ tlsConfigRegistry = make (map [string ]* tls.Config )
6163 }
6264
63- tlsConfigRegister [key ] = config
65+ tlsConfigRegistry [key ] = config
6466 tlsConfigLock .Unlock ()
6567 return nil
6668}
6769
6870// DeregisterTLSConfig removes the tls.Config associated with key.
6971func DeregisterTLSConfig (key string ) {
7072 tlsConfigLock .Lock ()
71- if tlsConfigRegister != nil {
72- delete (tlsConfigRegister , key )
73+ if tlsConfigRegistry != nil {
74+ delete (tlsConfigRegistry , key )
7375 }
7476 tlsConfigLock .Unlock ()
7577}
7678
7779func getTLSConfigClone (key string ) (config * tls.Config ) {
7880 tlsConfigLock .RLock ()
79- if v , ok := tlsConfigRegister [key ]; ok {
81+ if v , ok := tlsConfigRegistry [key ]; ok {
8082 config = cloneTLSConfig (v )
8183 }
8284 tlsConfigLock .RUnlock ()
0 commit comments