mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-26 16:41:21 +01:00
feat: #13790, allow ssl setup in psql
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
const nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
const winston = require('winston');
|
const winston = require('winston');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
@@ -32,6 +33,19 @@ connection.getConnectionOptions = function (postgres) {
|
|||||||
connectionTimeoutMillis: 90000,
|
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 || {});
|
return _.merge(connOptions, postgres.options || {});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user