diff --git a/plugins/database/mysql/connection_producer.go b/plugins/database/mysql/connection_producer.go index 4e34372005cd..bf4b6581aa29 100644 --- a/plugins/database/mysql/connection_producer.go +++ b/plugins/database/mysql/connection_producer.go @@ -218,7 +218,9 @@ func (c *mySQLConnectionProducer) addTLStoDSN() (connURL string, err error) { return "", fmt.Errorf("unable to parse connectionURL: %s", err) } - config.TLSConfig = c.tlsConfigName + if len(c.tlsConfigName) > 0 { + config.TLSConfig = c.tlsConfigName + } connURL = config.FormatDSN() diff --git a/plugins/database/mysql/connection_producer_test.go b/plugins/database/mysql/connection_producer_test.go index 7da5a05200d3..4213d57c4ff9 100644 --- a/plugins/database/mysql/connection_producer_test.go +++ b/plugins/database/mysql/connection_producer_test.go @@ -45,6 +45,11 @@ func Test_addTLStoDSN(t *testing.T) { tlsConfigName: "tlsTest101", expectedResult: "user:pa?ssword?@tcp(localhost:3306)/test?tls=tlsTest101&foo=bar", }, + "tls, valid tls parameter in query string": { + rootUrl: "user:password@tcp(localhost:3306)/test?tls=true", + tlsConfigName: "", + expectedResult: "user:password@tcp(localhost:3306)/test?tls=true", + }, } for name, test := range tests {