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"]