Closed
Description
Issue description
Follow these steps:
- Create an
x509.CertPool
and add a CA cert valid for two mysql servers (A and B). - Register a TLS config using this cert pool as the root CAs:
mysql.RegisterTLSConfig("custom", &tls.Config{ RootCAs: rootCertPool })
- Open a connection to a mysql server at hostname A with
tls=custom
. - Open a connection to a mysql server at hostname B with
tls=custom
.
Expected: The connection to server B succeeds.
Actual: The connection to server B fails with error: x509: certificate is valid for A, not B
See https://github.com/go-sql-driver/mysql/blob/master/dsn.go#L513 for the root cause. The registered config is mutated by the first connection (to A), and thereafter it can only be used to connect to A.
Configuration
Driver version (or git SHA): 2e00b5c
Go version: 1.7.1
Server version: MySQL 5.7
Server OS: Ubuntu 15.10