What is the best mysql Node.js module to connect to mysql over ssl?

I have created the application so far using node-mysql . I simply set up a secure mysql database using AWS RDS and successfully tested the SSL connection to the mysql command-line client. I have an Amazon.pem public key file. node-mysql does not seem to have an api for the SSL connection option.

The only thing I have found so far is Node-mysql-libmysqlclient , but I got errors trying to connect to it, something about the binding dependency being null, I'm not sure I have to trust it. Suggestions on which module / api to use? Alternatively, if you know what I need to change in node-mysql, I would like to work a little, but it looks like it uses lower-level sockets to connect to MySQL, so I'm not sure how difficult it would be to add the added part SSL

+6
source share
2 answers
var mysql = require('mysql'); var fs = require('fs'); var connection = mysql.createConnection({ host : 'localhost', user : 'me', password : 'secret', database : 'my_db', ssl : { ca : fs.readFileSync('./ssl/server-ca.pem'), // should be enough for AWS key : fs.readFileSync('./ssl/client-key.pem'), // required for google mysql cloud db cert : fs.readFileSync('./ssl/client-cert.pem'), // required for google mysql cloud db } }); 

which should do the trick.

+3
source

The node-mysql module supports ssl connections, as shown here: https://github.com/felixge/node-mysql#ssl-options .

0
source

Source: https://habr.com/ru/post/927213/


All Articles