Only check the certificate's host name if InsecureSkipVerify is not set.

This commit is contained in:
Mathias Gottschlag 2014-10-30 23:45:15 +01:00
parent 7a8cf41551
commit 1ff5be0d01

View File

@ -176,9 +176,15 @@ func (o Options) NewClient() (*Client, error) {
if strings.LastIndex(o.Host, ":") > 0 {
host = host[:strings.LastIndex(o.Host, ":")]
}
insecureSkipVerify := DefaultConfig.InsecureSkipVerify
if o.TLSConfig != nil {
insecureSkipVerify = o.TLSConfig.InsecureSkipVerify
}
if !insecureSkipVerify {
if err = tlsconn.VerifyHostname(host); err != nil {
return nil, err
}
}
client.conn = tlsconn
}