mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-10 17:42:52 +01:00
feat: #13790, allow ssl setup in psql
This commit is contained in:
@@ -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 || {});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user