From 124e7fa88d76cf11d7e0d7463eb124bddc2c1e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Fri, 31 Mar 2017 13:47:21 +0200 Subject: [PATCH] Use hostname from DSN as default for TLS if tls=true --- dsn.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dsn.go b/dsn.go index ac00dcedd..5c828bf90 100644 --- a/dsn.go +++ b/dsn.go @@ -494,6 +494,10 @@ func parseDSNParams(cfg *Config, params string) (err error) { if boolValue { cfg.TLSConfig = "true" cfg.tls = &tls.Config{} + host, _, err := net.SplitHostPort(cfg.Addr) + if err == nil { + cfg.tls.ServerName = host + } } else { cfg.TLSConfig = "false" }