From 6b6d67beb66fd6a1ff7bdace76723e4187166a3f Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 4 Sep 2020 12:51:48 -0700 Subject: [PATCH] fix: Allow disabling SSL for Postgres connection with standard PGSSLMODE env closes #1501 --- server/sequelize.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/server/sequelize.js b/server/sequelize.js index d6ad784be..faaf77c17 100644 --- a/server/sequelize.js +++ b/server/sequelize.js @@ -4,6 +4,7 @@ import Sequelize from "sequelize"; import EncryptedField from "sequelize-encrypted"; const isProduction = process.env.NODE_ENV === "production"; +const isSSLDisabled = process.env.PGSSLMODE === "disable"; export const encryptedFields = () => EncryptedField(Sequelize, process.env.SECRET_KEY); @@ -15,11 +16,12 @@ export const sequelize = new Sequelize(process.env.DATABASE_URL, { logging: debug("sql"), typeValidation: true, dialectOptions: { - ssl: isProduction - ? { - // Ref.: https://github.com/brianc/node-postgres/issues/2009 - rejectUnauthorized: false, - } - : false, + ssl: + isProduction && !isSSLDisabled + ? { + // Ref.: https://github.com/brianc/node-postgres/issues/2009 + rejectUnauthorized: false, + } + : false, }, });