From 40acde022213c98a09e7f01cc18adf79fafd0170 Mon Sep 17 00:00:00 2001 From: Dirkjan Bussink Date: Thu, 17 Jun 2021 14:51:43 +0200 Subject: [PATCH] Set the ServerName for TLS configuration (#988) When TLS hostname validation used for the MySQL connection, the ServerName property needs to be set so that it knows which name to validate on the certificate. Without this option and with InsecureSkipVerify set to false, validation will error here with a fatal error otherwise: ``` FATAL tls: either ServerName or InsecureSkipVerify must be specified in the tls.Config ``` --- go/mysql/connection.go | 1 + 1 file changed, 1 insertion(+) diff --git a/go/mysql/connection.go b/go/mysql/connection.go index 6855ee0..1c24a34 100644 --- a/go/mysql/connection.go +++ b/go/mysql/connection.go @@ -92,6 +92,7 @@ func (this *ConnectionConfig) UseTLS(caCertificatePath, clientCertificate, clien } this.tlsConfig = &tls.Config{ + ServerName: this.Key.Hostname, Certificates: certs, RootCAs: rootCertPool, InsecureSkipVerify: allowInsecure,