node-postgres icon indicating copy to clipboard operation
node-postgres copied to clipboard

Self signed certificate in certificate chain even after using rejectUnauthroized

Open yashcr07 opened this issue 3 years ago • 1 comments

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

yashcr07 avatar Dec 08 '22 08:12 yashcr07

https://node-postgres.com/features/ssl#usage-with-connectionstring says you if you use connectionString, your ssl stanza will be destroyed.

saper avatar Mar 12 '25 23:03 saper