Fix segfault in x509_cert (#4874)

This commit is contained in:
Fred Cox
2018-10-17 21:46:44 +03:00
committed by Greg
parent f10de93da4
commit 48745c3171
4 changed files with 28 additions and 2 deletions

View File

@@ -80,7 +80,10 @@ func (c *X509Cert) getCert(location string, timeout time.Duration) ([]*x509.Cert
}
defer ipConn.Close()
tlsCfg.ServerName = u.Host
if tlsCfg == nil {
tlsCfg = &tls.Config{}
}
tlsCfg.ServerName = u.Hostname()
conn := tls.Client(ipConn, tlsCfg)
defer conn.Close()