Feature: connect using TLS
See original GitHub issueIt would be nice if this mysql-driver supported connecting through TLS. This issue (to keep it simple) talks about one-way TLS, not including client-certificates.
Unfortunately, this does not mean it simply works by replacing tcp:// by tls://, as MySQL has its own protocol for that.
Basically, instead of the client immediately replying to the handshake with a HandshakeResponse, it first sends a SSLRequest to the server, then the server calls SSL_connect() which does the TLS handshake, and once a TLS session is up, the client resumes normally with a HandshakeResponse over that upgraded TLS connection.
Useful resources:
- OpenSSL --starttls mysql implementation
- MySQL Protocol TLS overview
- MySQL SSLRequest by the client after handshake from server
This would require some new fields in the ClientConfig:
// Pseudo-code, didn't check the syntax.
/**
* Client Config
*/
export interface ClientConfig {
tls?: {
// Path to a single file containing the CA certificate chain
ca?: string;
// Path to a directory containing the CAs to use, e.g. /etc/ssl/certs/
caPath?: string;
// The ssl-mode, one of DISABLED, PREFERRED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY
// See https://dev.mysql.com/doc/refman/5.7/en/connection-options.html#option_general_ssl-mode
mode: string = 'PREFERRED';
}
// ... and the existing fields
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Enable Transport Layer Security (TLS) 1.2 overview
Configuration Manager relies on many different components for secure communication. The protocol that's used for a given connection depends on ...
Read more >What is TLS & How Does it Work? | ISOC Internet Society
Transport Layer Security (TLS) encrypts data sent over the Internet to ensure hackers aren't able to see what you transmit. Read our guide...
Read more >What is Transport Layer Security? | TLS protocol | Cloudflare
Transport Layer Security (TLS) is an encryption protocol that protects ... A TLS connection is initiated using a sequence known as the TLS...
Read more >Using TLS with z/OS Connect EE - IBM Community
In order to configure TLS with z/OS Connect EE you must define the ssl-1.0 (or appSecurity-2.0) feature in server.xml and then use the...
Read more >HTTPS (HTTP Secure or HTTP over TLS) - Squid Cache Wiki
Squid SslBump and associated features can be used to decrypt HTTPS CONNECT tunnels while they pass through a Squid proxy. This allows dealing...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Here’s my branch with the basic mechanics for getting TLS working.
Examples:
Things missing:
startTlsI currently don’t have time to work on this any further for at least a couple of weeks, but feel free to use my branch as the basis for a proper implementation.
Just testing @codeflows TLS branch to connect to PlanetScale Mysql DB to a great success! Thanks @codeflows I hope you can create a PR on this.