Node.js based forum software built for the modern web
feat: #13790, allow ssl setup in psql
Barış Soner Uşaklı5bd1f7b7ac95
diff --git a/src/database/postgres/connection.js b/src/database/postgres/connection.jsindex 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 || {});};