Skip to content

Enabling support for TLS-verified mysql server#84

Open
g-saransh wants to merge 2 commits intoprestodb:mainfrom
g-saransh:mysql_tls
Open

Enabling support for TLS-verified mysql server#84
g-saransh wants to merge 2 commits intoprestodb:mainfrom
g-saransh:mysql_tls

Conversation

@g-saransh
Copy link
Copy Markdown

@g-saransh g-saransh commented Mar 31, 2026

This PR adds support for TLS-verified mysql server. By default, it maintains the original behavior of disabling TLS verification.

For simple TLS,

"tls": true,
"caCertPath": "/path/to/CA/certificate"

For mutual TLS,

"tls": true,
"caCertPath": "/path/to/CA/certificate",
"clientCertPath": "/path/to/client/certificate",
"clientkeyPath": "/path/to/client/key"

@g-saransh g-saransh requested a review from ethanyzhang as a code owner March 31, 2026 01:00
@wanglinsong wanglinsong requested a review from yabinma April 1, 2026 07:47
utils/utils.go Outdated
if db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?parseTime=true",
mySQLCfg.Username, mySQLCfg.Password, mySQLCfg.Server, mySQLCfg.Database)); err != nil {
if db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/%s?tls=%t&parseTime=true",
mySQLCfg.Username, mySQLCfg.Password, mySQLCfg.Server, mySQLCfg.Database, mySQLCfg.Tls)); err != nil {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Note: the corresponding CA certificate should be added to the system's trust store for TLS verification to work." Agree. It has to add the CA in the system truststore. It's possible to add a complete solution so that customized CA can be specified as well(a ca path maybe)?

Copy link
Copy Markdown
Author

@g-saransh g-saransh Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for the comment Yabin. I have added logic to handle custom certificate path. For completeness, I also added support for mutual TLS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants