From 706b760495f3e207b01c124400ff668fd29266b2 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 31 Aug 2017 09:15:34 -0400 Subject: [PATCH 1/2] Use net.SplitHostPort on Consul address Fixes #3267 --- physical/consul/consul.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/physical/consul/consul.go b/physical/consul/consul.go index 8256808b1a13..4430dd3ff5d8 100644 --- a/physical/consul/consul.go +++ b/physical/consul/consul.go @@ -241,7 +241,10 @@ 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"]) + if err != nil { + return nil, err + } insecureSkipVerify := false if _, ok := conf["tls_skip_verify"]; ok { @@ -262,7 +265,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"] From c22defd138f24530ecd291bef794d91666f24627 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Thu, 31 Aug 2017 09:57:40 -0400 Subject: [PATCH 2/2] Enable bare IPs too --- physical/consul/consul.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/physical/consul/consul.go b/physical/consul/consul.go index 4430dd3ff5d8..6c3146683e72 100644 --- a/physical/consul/consul.go +++ b/physical/consul/consul.go @@ -242,7 +242,11 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe func setupTLSConfig(conf map[string]string) (*tls.Config, error) { serverName, _, err := net.SplitHostPort(conf["address"]) - if err != nil { + switch { + case err == nil: + case strings.Contains(err.Error(), "missing port"): + serverName = conf["address"] + default: return nil, err }