diff --git a/pkg/config/config.go b/pkg/config/config.go index 89e040b4..1388ba93 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -8,7 +8,6 @@ import ( "github.com/jessevdk/go-flags" "github.com/pkg/errors" "io/ioutil" - "net" "os" ) @@ -94,8 +93,8 @@ type TLS struct { Insecure bool `yaml:"insecure"` } -// MakeConfig assembles a tls.Config from t and address. -func (t *TLS) MakeConfig(address string) (*tls.Config, error) { +// MakeConfig assembles a tls.Config from t and serverName. +func (t *TLS) MakeConfig(serverName string) (*tls.Config, error) { if !t.Enable { return nil, nil } @@ -130,11 +129,7 @@ func (t *TLS) MakeConfig(address string) (*tls.Config, error) { } } - if host, _, err := net.SplitHostPort(address); err == nil { - tlsConfig.ServerName = host - } else { - tlsConfig.ServerName = address - } + tlsConfig.ServerName = serverName return tlsConfig, nil } diff --git a/pkg/config/database.go b/pkg/config/database.go index 9766af5b..b42ff8e1 100644 --- a/pkg/config/database.go +++ b/pkg/config/database.go @@ -63,7 +63,7 @@ func (d *Database) Open(logger *logging.Logger) (*icingadb.DB, error) { config.Timeout = time.Minute config.Params = map[string]string{"sql_mode": "ANSI_QUOTES"} - tlsConfig, err := d.TlsOptions.MakeConfig(config.Addr) + tlsConfig, err := d.TlsOptions.MakeConfig(d.Host) if err != nil { return nil, err }