Add allowUnauthorizedCerts to Postgres-Node

This commit is contained in:
Jan Oberhauser
2020-08-25 17:02:01 +02:00
parent 2c9e589c72
commit 88b0147292
2 changed files with 24 additions and 3 deletions

View File

@@ -189,16 +189,23 @@ export class Postgres implements INodeType {
const pgp = pgPromise();
const config = {
const config: IDataObject = {
host: credentials.host as string,
port: credentials.port as number,
database: credentials.database as string,
user: credentials.user as string,
password: credentials.password as string,
ssl: !['disable', undefined].includes(credentials.ssl as string | undefined),
sslmode: (credentials.ssl as string) || 'disable',
};
if (credentials.allowUnauthorizedCerts === true) {
config.ssl = {
rejectUnauthorized: false,
};
} else {
config.ssl = !['disable', undefined].includes(credentials.ssl as string | undefined);
config.sslmode = (credentials.ssl as string) || 'disable';
}
const db = pgp(config);
let returnItems = [];