Skip to content

Commit ece1bcc

Browse files
iaburtonploxiln
authored andcommittedDec 24, 2019
fix tls.Config copy to properly handle embedded locks etc
also move tls.Config clone after net.SplitHostPort closes nsqio#254
1 parent 5dd0672 commit ece1bcc

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
 

‎conn.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -384,18 +384,19 @@ func (c *Conn) identify() (*IdentifyResponse, error) {
384384
}
385385

386386
func (c *Conn) upgradeTLS(tlsConf *tls.Config) error {
387-
// create a local copy of the config to set ServerName for this connection
388-
var conf tls.Config
389-
if tlsConf != nil {
390-
conf = *tlsConf
391-
}
392387
host, _, err := net.SplitHostPort(c.addr)
393388
if err != nil {
394389
return err
395390
}
391+
392+
// create a local copy of the config to set ServerName for this connection
393+
conf := &tls.Config{}
394+
if tlsConf != nil {
395+
conf = tlsConf.Clone()
396+
}
396397
conf.ServerName = host
397398

398-
c.tlsConn = tls.Client(c.conn, &conf)
399+
c.tlsConn = tls.Client(c.conn, conf)
399400
err = c.tlsConn.Handshake()
400401
if err != nil {
401402
return err

0 commit comments

Comments
 (0)
Please sign in to comment.