Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS support for database protocols #515

Closed
sunng87 opened this issue Nov 15, 2022 · 4 comments · Fixed by #641
Closed

TLS support for database protocols #515

sunng87 opened this issue Nov 15, 2022 · 4 comments · Fixed by #641
Assignees
Labels
C-enhancement Category Enhancements
Milestone

Comments

@sunng87
Copy link
Member

sunng87 commented Nov 15, 2022

Both mysql and postgresql shares same port of plain-text connection and secure one. Unlike http or grpc transports, database protocols have their own tls handshake process. So we might not be able to utilize haproxy or cloud load balancer for tls termination. Tls support has to be implemented in database side. Task including:

  • provide option to configure certs/key for mysql/postgresql
  • load configured certs/key from file system
  • start mysql/postgresql port with tls acceptor
  • add session information about whether a connection is secure or not

We can provide options to restrict insecure connection access in future

@sunng87 sunng87 added the C-enhancement Category Enhancements label Nov 15, 2022
@SSebo
Copy link
Contributor

SSebo commented Nov 16, 2022

@sunng87 Should TLS acceptor be added in following location?

async fn start(&self, listening: SocketAddr) -> Result<SocketAddr> {

async fn start(&self, listening: SocketAddr) -> Result<SocketAddr> {

@sunng87
Copy link
Member Author

sunng87 commented Nov 16, 2022

Yes, at least we need some configuration to enable TLS.

For postgres, using pgwire, TLS is already supported via this option, which is set to None to disable. There is an example in pgwire to demo its usage.

For MySQL, I haven't got time investigate its library support for TLS, we probably need to work with upstream and upstream of upstream for the support.

When all protocol level supported finished, we need to add last-mile configuration to manage and load cert/key files.

@SSebo
Copy link
Contributor

SSebo commented Nov 16, 2022

For MySQL, looks like there is one issue about this.
I will try to port jonhoo/msql-srv#23 implementation to opensrv-mysql.

@SSebo
Copy link
Contributor

SSebo commented Nov 21, 2022

I made a PR to opensrv-mysql to support MySQL TLS databendlabs/opensrv#34

@sunng87 sunng87 linked a pull request Nov 29, 2022 that will close this issue
2 tasks
@xtang xtang mentioned this issue Nov 30, 2022
24 tasks
@xtang xtang added this to the Release v0.1 milestone Nov 30, 2022
@fengjiachun fengjiachun modified the milestones: v0.3, v0.1 Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category Enhancements
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants