Node-postgres: Cert-based authentication broken

Created on 27 Oct 2020  路  3Comments  路  Source: brianc/node-postgres

Starting yesterday with the upgrade to 8.4.2, connections now fail with the error message: error: connection requires a valid client certificate.

It appears that the switch to making the ssl key not enumerable means that the key is no longer copied because Object.assign() only works with enumerable properties.

This became much trickier to debug since the pg dependency on pg-pool allows for minor version upgrades. We downgraded to 7.17.0 to fix things for the short term.

Thanks

bug

Most helpful comment

baaaah sorry about that breakage! 馃槮 馃槮 馃槮 Looks like charmander is already working on a fix for it, which is rad.

All 3 comments

We are also experiencing this same issue in two of our projects

Almost lost my mind today with that 馃槄

I had upgraded several dependencies and could not figure out what the problem was before reverting my upgrades and re-trying each of them one by one.

Sticking to pg 8.4.1 works for me at the moment, using it with knex:

const configuration = {
  client: 'pg',
  connection: {
    database: process.env.DATABASE_NAME,
    host: process.env.DATABASE_HOST,
    port: parseInt(process.env.DATABASE_PORT || '5432'),
    user: process.env.DATABASE_USERNAME,
    password: process.env.DATABASE_PASSWORD,
    ssl:
      process.env.DATABASE_SSL_CERT && process.env.DATABASE_SSL_KEY
        ? {
            host: process.env.DATABASE_SSL_HOST,
            ca: process.env.DATABASE_SSL_CA
              ? fs.readFileSync(process.env.DATABASE_SSL_CA)
              : undefined,
            cert: fs.readFileSync(process.env.DATABASE_SSL_CERT),
            key: fs.readFileSync(process.env.DATABASE_SSL_KEY)
          }
        : false
  }
};

baaaah sorry about that breakage! 馃槮 馃槮 馃槮 Looks like charmander is already working on a fix for it, which is rad.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

wrod7 picture wrod7  路  4Comments

chrisjensen picture chrisjensen  路  4Comments

dipakdas99 picture dipakdas99  路  3Comments

KeynesYouDigIt picture KeynesYouDigIt  路  3Comments

LukeSchlangen picture LukeSchlangen  路  4Comments