Last active
January 2, 2020 03:41
-
-
Save jackson-elfers/f5575e7b2f9a3c2e9b263360fdf01710 to your computer and use it in GitHub Desktop.
Update Your Amazon RDS SSL/TLS Certificates by February 5, 2020 nodejs, mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
AWS will be updating ssl certs next month and have set a hard deadline of Feb 5th 2020. | |
If working with nodejs and the mysql npm package you'll need to obtain the newest | |
cert to connect via ssl. Below shows how to connect your cert using the ssl option. | |
Obtain the cert from AWS here (CA-2019): | |
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.SSL.html | |
``` | |
require('dotenv').config(); | |
const fs = require("fs"); | |
const path = require("path"); | |
const mysql = require('mysql'); | |
const connection = mysql.createConnection({ | |
host: process.env.MYSQL_HOST, | |
user: process.env.MYSQL_USER, | |
password: process.env.MYSQL_PASSWORD, | |
database: process.env.MYSQL_DATABASE, | |
ssl: { ca: fs.readFileSync(path.join(__dirname, "./rds-ca-2019-root.pem")) } | |
}); | |
connection.connect(function(error){ | |
if(error) { | |
console.log(error); | |
} | |
else { | |
console.log("database connected successfully!"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment