Skip to content

Commit 40acde0

Browse files
authored
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 ```
1 parent 9bc508f commit 40acde0

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

go/mysql/connection.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ func (this *ConnectionConfig) UseTLS(caCertificatePath, clientCertificate, clien
9292
}
9393

9494
this.tlsConfig = &tls.Config{
95+
ServerName: this.Key.Hostname,
9596
Certificates: certs,
9697
RootCAs: rootCertPool,
9798
InsecureSkipVerify: allowInsecure,

0 commit comments

Comments
 (0)