From d1a5509d643f0e70d2a069ec99b3326d1f302812 Mon Sep 17 00:00:00 2001 From: felix Date: Wed, 25 Aug 2021 12:12:47 +0200 Subject: [PATCH] Bugfix: ssl and isNative=true If pg-native is used together with SSL, the parameter `?ssl=true` needs different translation. --- lib/index.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 39324d9..57ac6e1 100644 --- a/lib/index.js +++ b/lib/index.js @@ -83,8 +83,20 @@ module.exports = Adapter => class PostgreSQLAdapter extends Adapter { user, password, host: params.hostname, - port: params.port, - ssl: 'ssl' in params.query + port: params.port + } + + if(params.query['ssl']) { + //TODO: note probably in some future, more sslModes should be supported + console.log('ssl mode detected') + if(isNative) { + console.info(`Translating to sslMode=require`) + connection['sslMode'] = 'require' + } + else { + console.info(`Translating to ssl=true`) + connection['ssl'] = true + } } }