node-postgres
node-postgres copied to clipboard
Self signed certificate in certificate chain even after using rejectUnauthroized
I have an Azure Postgres instance, and I am trying to connect to it but getting Self signed certificate in certificate chain error.
I am able to connect using psql with sslmode=require param
Below is my code snippet
Since my password contains certain special characters i've used encodeURIComponent, and its managed by my org so I can't change it.
const getDBUrl = () => {
return `postgres://${DB_USERNAME}:${encodeURIComponent(DB_PASSWORD)}@${DB_HOSTNAME}:${DB_PORT}/${DB_NAME}`;
};
const newPgPool = new Pool({
connectionString: getDBUrl(),
ssl: {
rejectUnauthorized: false,
}
});
As far as i know, setting rejectUnauthorized: false would use SSL but won't reject self signed certs.
Node: 16.14.0 pg: 8.8.0
https://node-postgres.com/features/ssl#usage-with-connectionstring says you if you use connectionString, your ssl stanza will be destroyed.