Google Cloud PG とpg-promiseでも同様のニーズがありました。?ssl=true
( を使用して)得たエラーは でしたconnection requires a valid client certificate
。
SSL 接続は文書化されていませんが、 node-postgrespg-promise
で構築されています。リンクで説明されているように、構成パラメーターは次のもの以上のものにすることができます。ssl
true
const pgp = require('pg-promise')();
const fs = require('fs');
const connectionConf = {
host: 'myhost.com',
port: 5432,
database: 'specific_db_name',
user: 'my_App_user',
password: 'aSecretePass',
ssl: {
rejectUnauthorized : false,
ca : fs.readFileSync("server-ca.pem").toString(),
key : fs.readFileSync("client-key.pem").toString(),
cert : fs.readFileSync("client-cert.pem").toString(),
}
};
const new_db = pgp(connectionConf);
new_db.any('SELECT * FROM interesting_table_a LIMIT 10')
.then(res => {console.log(res);})
.catch(err => {console.error(err);})
.then(() => {new_db.$pool.end()});