From 0bfa252339520dea45962b6b70d09fe58a5cf447 Mon Sep 17 00:00:00 2001 From: Rob Hedgpeth Date: Tue, 31 Mar 2020 10:01:33 -0500 Subject: [PATCH] SSL code snippets and backing comments --- bookings/src/db.js | 16 +++++++++++----- flights/src/db.js | 12 ++++++++++++ orders/src/db.js | 24 ++++++++++-------------- places/src/db.js | 12 ++++++++++++ 4 files changed, 45 insertions(+), 19 deletions(-) diff --git a/bookings/src/db.js b/bookings/src/db.js index 06c9365..9bef0d4 100644 --- a/bookings/src/db.js +++ b/bookings/src/db.js @@ -1,6 +1,12 @@ var mariadb = require('mariadb'); require('dotenv').config(); +// SSL (e.g. SkySQL) connections +// * Remember to change the location of "skysql_chain.pem" to wherever you placed it! +// * To use just uncomment the two lines below and the 'ssl' property (and value) + +//const fs = require("fs"); +//const serverCert = [fs.readFileSync("skysql_chain.pem", "utf8")]; const pool = mariadb.createPool({ host: process.env.DB_HOST, @@ -9,11 +15,11 @@ const pool = mariadb.createPool({ port: process.env.DB_PORT, multipleStatements: true, connectionLimit: 5 - /*timezone: 'UTC', - dateStrings: [ - 'DATE', - 'DATETIME' - ]*/ + // For SSL (e.g. SkySQL) connections + /* + ,ssl: { + ca: serverCert + }*/ }); diff --git a/flights/src/db.js b/flights/src/db.js index e16640b..ba0bda3 100644 --- a/flights/src/db.js +++ b/flights/src/db.js @@ -1,6 +1,13 @@ var mariadb = require('mariadb'); require('dotenv').config(); +// SSL (e.g. SkySQL) connections +// * Remember to change the location of "skysql_chain.pem" to wherever you placed it! +// * To use just uncomment the two lines below and the 'ssl' property (and value) + +//const fs = require("fs"); +//const serverCert = [fs.readFileSync("skysql_chain.pem", "utf8")]; + const pool = mariadb.createPool({ host: process.env.DB_HOST, user: process.env.DB_USER, @@ -9,6 +16,11 @@ const pool = mariadb.createPool({ database: process.env.DB_NAME, multipleStatements: true, connectionLimit: 5 + // For SSL (e.g. SkySQL) connections + /* + ,ssl: { + ca: serverCert + }*/ }); module.exports={ diff --git a/orders/src/db.js b/orders/src/db.js index 284d47a..99557b0 100644 --- a/orders/src/db.js +++ b/orders/src/db.js @@ -1,8 +1,11 @@ -const fs = require("fs"); var mariadb = require('mariadb'); require('dotenv').config(); -// For SSL connections +// SSL (e.g. SkySQL) connections +// * Remember to change the location of "skysql_chain.pem" to wherever you placed it! +// * To use just uncomment the two lines below and the 'ssl' property (and value) + +//const fs = require("fs"); //const serverCert = [fs.readFileSync("skysql_chain.pem", "utf8")]; var pools = [ @@ -14,19 +17,12 @@ var pools = [ database: process.env.DB_NAME_1, multipleStatements: true, connectionLimit: 5 - })/*, - mariadb.createPool({ - host: '', - user:'', - password: '', - database: 'orders', - port: 5002, - multipleStatements: true, - connectionLimit: 5, - ssl: { + // For SSL (e.g. SkySQL) connections + /* + ,ssl: { ca: serverCert - } - })*/ + }*/ + }) ]; module.exports={ diff --git a/places/src/db.js b/places/src/db.js index d367d6e..4a34946 100644 --- a/places/src/db.js +++ b/places/src/db.js @@ -1,6 +1,13 @@ var mariadb = require('mariadb'); require('dotenv').config(); +// SSL (e.g. SkySQL) connections +// * Remember to change the location of "skysql_chain.pem" to wherever you placed it! +// * To use just uncomment the two lines below and the 'ssl' property (and value) + +//const fs = require("fs"); +//const serverCert = [fs.readFileSync("skysql_chain.pem", "utf8")]; + const pool = mariadb.createPool({ host: 'localhost', user:'root', @@ -8,6 +15,11 @@ const pool = mariadb.createPool({ database: 'Places', multipleStatements: true, connectionLimit: 5 + // For SSL (e.g. SkySQL) connections + /* + ,ssl: { + ca: serverCert + }*/ }); const pool = mariadb.createPool({