Skip to content

Enabling support for TLS-verified mysql server#84

Open
g-saransh wants to merge 1 commit into
prestodb:mainfrom
g-saransh:mysql_tls
Open

Enabling support for TLS-verified mysql server#84
g-saransh wants to merge 1 commit into
prestodb: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 simple TLS-verified mysql server. By default, it maintains the original behavior of disabling TLS verification.

Add the following fields in mysql.json for TLS,

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

@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
Comment thread utils/utils.go Outdated
Comment thread mysql.template.json Outdated
Comment thread 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.

Copy link
Copy Markdown
Collaborator

@ethanyzhang ethanyzhang left a comment

Choose a reason for hiding this comment

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

Thanks for the patch. There should also be tests for this as well.

Comment thread utils/utils.go Outdated
}
if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
log.Error().Msg("failed to append CA certificate")
return nil, err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

err here will be nil.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This is the path for !ok. The intent is to return an error if appending the certificate fails.

Comment thread utils/utils.go Outdated
Comment thread mysql.template.json Outdated
Comment thread utils/utils.go Outdated
Comment thread utils/utils.go Outdated
@ethanyzhang
Copy link
Copy Markdown
Collaborator

Please update the PR, commit messages should follow semantic commit message convention.

@wanglinsong
Copy link
Copy Markdown
Member

We can simplify the PR by removing mTLS; pbench is not a typical mTLS use case.

@g-saransh g-saransh force-pushed the mysql_tls branch 2 times, most recently from c4e5122 to 30dc9db Compare April 13, 2026 22:26
@g-saransh
Copy link
Copy Markdown
Author

@ethanyzhang I have updated the PR, addressing your comments. I also rebased and updated the commit message to follow semantic commit message convention.

@g-saransh
Copy link
Copy Markdown
Author

g-saransh commented Apr 13, 2026

We can simplify the PR by removing mTLS; pbench is not a typical mTLS use case.

I added mTLS for completeness. But if we feel it's not relevant here, I can remove it.

@g-saransh g-saransh requested a review from ethanyzhang April 13, 2026 22:30
@wanglinsong
Copy link
Copy Markdown
Member

We can simplify the PR by removing mTLS; pbench is not a typical mTLS use case.

I added mTLS for completeness. But if we feel it's not relevant here, I can remove it.

Yes, please. The hosts that run the pbench and pbench itself are not provisioned/built with client certificates.

- Update mysql.template.json with new TLS options
- Handle custom TLS configuration
- Add tests
@g-saransh
Copy link
Copy Markdown
Author

g-saransh commented Apr 14, 2026

We can simplify the PR by removing mTLS; pbench is not a typical mTLS use case.

I added mTLS for completeness. But if we feel it's not relevant here, I can remove it.

Yes, please. The hosts that run the pbench and pbench itself are not provisioned/built with client certificates.

Got it. Removed mutual TLS code. Thanks @wanglinsong.

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.

4 participants