feat: #13790, allow ssl setup in psql

This commit is contained in:
Barış Soner Uşaklı
2025-12-01 17:46:01 -05:00
parent 59f649b885
commit 5bd1f7b7ac

View File

@@ -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 || {});
};