Skip to content

Commit

Permalink
Merge pull request #255 from iaburton/tlsConfig-copy-fix
Browse files Browse the repository at this point in the history
TLS Config copy fix
  • Loading branch information
ploxiln authored Dec 24, 2019
2 parents 5dd0672 + ece1bcc commit 4b82735
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,19 @@ func (c *Conn) identify() (*IdentifyResponse, error) {
}

func (c *Conn) upgradeTLS(tlsConf *tls.Config) error {
// create a local copy of the config to set ServerName for this connection
var conf tls.Config
if tlsConf != nil {
conf = *tlsConf
}
host, _, err := net.SplitHostPort(c.addr)
if err != nil {
return err
}

// create a local copy of the config to set ServerName for this connection
conf := &tls.Config{}
if tlsConf != nil {
conf = tlsConf.Clone()
}
conf.ServerName = host

c.tlsConn = tls.Client(c.conn, &conf)
c.tlsConn = tls.Client(c.conn, conf)
err = c.tlsConn.Handshake()
if err != nil {
return err
Expand Down

0 comments on commit 4b82735

Please sign in to comment.