Skip to content

Commit 481dc97

Browse files
committedJun 19, 2013
Add support for customizing tls.Config
1 parent 0a17480 commit 481dc97

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
 

‎tlsconfig.go

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package mysql
2+
3+
import (
4+
"crypto/tls"
5+
)
6+
7+
type TLSConfig interface {
8+
SetTLSConfig(key string, config *tls.Config)
9+
}
10+
11+
var tlsConfigMap = make(map[string]*tls.Config)
12+
13+
func (d *mysqlDriver) SetTLSConfig(key string, config *tls.Config) {
14+
tlsConfigMap[key] = config
15+
}

‎utils.go

+3
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ func parseDSN(dsn string) (cfg *config, err error) {
152152
cfg.tls = &tls.Config{}
153153
} else if strings.ToLower(value) == "skip-verify" {
154154
cfg.tls = &tls.Config{InsecureSkipVerify: true}
155+
} else if tlsConfig, ok := tlsConfigMap[value]; ok {
156+
cfg.tls = &tls.Config{}
157+
*cfg.tls = *tlsConfig
155158
}
156159

157160
default:

0 commit comments

Comments
 (0)
Please sign in to comment.