From 7585349e46ec79248e4a176a679ea9998f650302 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 31 Aug 2017 12:31:34 -0400 Subject: [PATCH] Use net.SplitHostPort on Consul address (#3268) --- physical/consul/consul.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/physical/consul/consul.go b/physical/consul/consul.go index 8256808b1..6c3146683 100644 --- a/physical/consul/consul.go +++ b/physical/consul/consul.go @@ -241,7 +241,14 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe } func setupTLSConfig(conf map[string]string) (*tls.Config, error) { - serverName := strings.Split(conf["address"], ":") + serverName, _, err := net.SplitHostPort(conf["address"]) + switch { + case err == nil: + case strings.Contains(err.Error(), "missing port"): + serverName = conf["address"] + default: + return nil, err + } insecureSkipVerify := false if _, ok := conf["tls_skip_verify"]; ok { @@ -262,7 +269,7 @@ func setupTLSConfig(conf map[string]string) (*tls.Config, error) { tlsClientConfig := &tls.Config{ MinVersion: tlsMinVersion, InsecureSkipVerify: insecureSkipVerify, - ServerName: serverName[0], + ServerName: serverName, } _, okCert := conf["tls_cert_file"]