Skip to content

Commit 6898fad

Browse files
Rebecca Chindprotaso
Rebecca Chin
authored andcommitted
Don't mutate registered tls configs
Signed-off-by: Dave Protasowski <[email protected]>
1 parent 382e13d commit 6898fad

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

AUTHORS

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Carlos Nieto <jose.carlos at menteslibres.net>
1818
Chris Moos <chris at tech9computers.com>
1919
Daniel Nichter <nil at codenode.com>
2020
Daniël van Eeden <git at myname.nl>
21+
Dave Protasowski <dprotaso at gmail.com>
2122
DisposaBoy <disposaboy at dby.me>
2223
Egor Smolyakov <egorsmkv at gmail.com>
2324
Frederick Mayle <frederickmayle at gmail.com>
@@ -46,6 +47,7 @@ Nicola Peduzzi <thenikso at gmail.com>
4647
Olivier Mengué <dolmen at cpan.org>
4748
Paul Bonser <misterpib at gmail.com>
4849
Peter Schultz <peter.schultz at classmarkets.com>
50+
Rebecca Chin <rchin at pivotal.io>
4951
Runrioter Wung <runrioter at gmail.com>
5052
Soroush Pour <me at soroushjp.com>
5153
Stan Putrya <root.vagner at gmail.com>
@@ -60,3 +62,4 @@ Zhenye Xie <xiezhenye at gmail.com>
6062
Barracuda Networks, Inc.
6163
Google Inc.
6264
Stripe Inc.
65+
Pivotal Inc.

dsn.go

+2
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ func parseDSNParams(cfg *Config, params string) (err error) {
511511
}
512512

513513
if tlsConfig, ok := tlsConfigRegister[name]; ok {
514+
tlsConfig = tlsConfig.Clone()
515+
514516
if len(tlsConfig.ServerName) == 0 && !tlsConfig.InsecureSkipVerify {
515517
host, _, err := net.SplitHostPort(cfg.Addr)
516518
if err == nil {

dsn_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ func TestDSNWithCustomTLS(t *testing.T) {
159159
t.Error(err.Error())
160160
} else if cfg.tls.ServerName != name {
161161
t.Errorf("did not get the correct ServerName (%s) parsing DSN (%s).", name, tst)
162+
} else if tlsCfg.ServerName != "" {
163+
t.Errorf("tlsCfg was mutated ServerName (%s) should be empty parsing DSN (%s).", name, tst)
162164
}
163165

164166
DeregisterTLSConfig("utils_test")

0 commit comments

Comments
 (0)