diff --git a/src/database/postgres/connection.js b/src/database/postgres/connection.js index 19d796d7ed..34a7bca5e8 100644 --- a/src/database/postgres/connection.js +++ b/src/database/postgres/connection.js @@ -1,5 +1,6 @@ 'use strict'; +const fs = require('fs'); const nconf = require('nconf'); const winston = require('winston'); const _ = require('lodash'); @@ -32,6 +33,19 @@ connection.getConnectionOptions = function (postgres) { connectionTimeoutMillis: 90000, }; + if (typeof postgres.ssl === 'object' && !Array.isArray(postgres.ssl) && postgres.ssl !== null) { + const { ssl } = postgres; + connOptions.ssl = { + rejectUnauthorized: ssl.rejectUnauthorized, + }; + ['ca', 'key', 'cert'].forEach((prop) => { + if (ssl.hasOwnProperty(prop)) { + connOptions.ssl[prop] = fs.readFileSync(ssl[prop]).toString(); + } + }); + console.log(connOptions); + } + return _.merge(connOptions, postgres.options || {}); };