node-mysql2 icon indicating copy to clipboard operation
node-mysql2 copied to clipboard

Server with SSL?

Open arei opened this issue 4 years ago • 5 comments

Is it possible to use Mysql2 in server mode with the server using SSL? If not, should it be able to do so? Just enabling SSL with capabilityFlags doesnt seem to work, plus there is no way to currently pass any configuration for connections in through server and the ServerHandshake command does not seem to support it.

Just want to make sure I am not missing something.

arei avatar Nov 17 '20 14:11 arei

need to double check, definitely not possible with just a config option ( but I'm keen to add this functionality )

sidorares avatar Nov 17 '20 14:11 sidorares

For fun I did add a way to pass config options into the server connection, but when I enable SSL in the capabilityFlags I get invalid commands, presumably because they are encrypted and nothing decrypts them.

arei avatar Nov 17 '20 14:11 arei

if you want to hack on this the help would be definitely appreciated Documentation on SSL negotiation and upgrade: https://dev.mysql.com/doc/internals/en/ssl.html Code on the client side: https://github.com/sidorares/node-mysql2/blob/ebc2cb438d380d81d57ae6e2d227bfafc684eb2a/lib/commands/client_handshake.js#L121

sidorares avatar Nov 17 '20 14:11 sidorares

Also in need of running a mysql2 server with SSL support. Traced things through to where the SSL client request is being mis-parsed because it's assumed to be a handshake response. I'm up for putting in some effort to create a patch.

KrisBraun avatar Oct 26 '23 16:10 KrisBraun

Ended up simply putting a terminating SSL proxy in front. Works great!

KrisBraun avatar Oct 30 '23 13:10 KrisBraun