Closed shengjiangfeng closed 2 months ago
https://github.com/go-sql-driver/mysql?tab=readme-ov-file#loc
Please keep in mind, that param values must be url.QueryEscape'ed. Alternatively you can manually replace the / with %2F. For example US/Pacific would be loc=US%2FPacific.
I try to add url.QueryEscape(ssl-ca-path) , but i will get another x509 error. The dsn cannot parse ssl-ca path correctly.
new dsn is admin:pwd@tcp(host:3306)/mysql?tls=true&allowCleartextPasswords=true&ssl-ca=%2Ftmp%2Fbundle.pem
panic: tls: failed to verify certificate: x509: certificate signed by unknown authority
goroutine 1 [running]:
main.GetClient()
/usr/local/src/pro/main.go:79 +0x399
main.main()
/usr/local/src/pro/main.go:85 +0x13
exit status 2
My env is in aws, i visit aurora-mysql use iam-role. The aws requires me to provide ssl-ca-path.
I know, this lib does not contain a param named ssl-ca, but how can i connect to mysql use ssl & ssl-ca ?
https://pkg.go.dev/github.com/go-sql-driver/mysql?utm_source=godoc#Config
You can set tls.Config object to Config.TLS.
Fixed, thanks very much!
Issue description
I want to use dsn in golang to connect mysql8.0.
My dsn is like admin:pwd@tcp(host:3306)/mysql?allowCleartextPasswords=true&ssl-ca=/tmp/bundle.pem. But get errInvalidDSNUnescaped error.
Example code
Error log
Configuration
*Driver version (or git SHA):1.8.1
*Go version:1.21
*Server version:MySQL 8.0
*Server OS: ubuntu:22.04
bug code go-sql-driver/mysql@v1.8.1/dsn.go