I've built my app so far using node-mysql. I just set up a securely accessible mysql database using AWS RDS service and have tested an SSL connection successfully with the mysql command line client. I have Amazon's public key .pem file. node-mysql doesn't seem to have an api for the SSL connect option.
The only one I've found so far is Node-mysql-libmysqlclient but I got errors trying to connect with it, something about a bindings dependency being null so I'm not sure if I should trust it. Suggestions of which module/api to use? Alternatively, if you know what I need to modify in node-mysql I'd be willing to tinker a bit but it looks like it's using lower level Sockets to connect to MySQL so I'm not sure how hard it would be to get the SSL part added on.
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
}
});
that should do the trick.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With