From 1ff5be0d01b5b64cb55af8a8ee542635972f4452 Mon Sep 17 00:00:00 2001 From: Mathias Gottschlag Date: Thu, 30 Oct 2014 23:45:15 +0100 Subject: [PATCH] Only check the certificate's host name if InsecureSkipVerify is not set. --- xmpp.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xmpp.go b/xmpp.go index b3b8b20..129eb40 100644 --- a/xmpp.go +++ b/xmpp.go @@ -176,8 +176,14 @@ func (o Options) NewClient() (*Client, error) { if strings.LastIndex(o.Host, ":") > 0 { host = host[:strings.LastIndex(o.Host, ":")] } - if err = tlsconn.VerifyHostname(host); err != nil { - return nil, err + 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 }