Question

Error: self signed certificate in certificate

Posted about 15 hours ago 55 views
Node.jsPostgreSQLDigitalOcean 1-Click Apps MarketplaceDatabasesDigitalOcean Managed PostgreSQL Database

My app cannot connect to the managed database instance I just created because of the following error:

[2022-01-05 11:20:18] yarn run v1.22.17
[2022-01-05 11:20:18] $ NODE_ENV=production node build/server.js
[2022-01-05 11:20:21] > App started http://localhost:3000
[2022-01-05 11:20:21] node:internal/process/promises:246
[2022-01-05 11:20:21]           triggerUncaughtException(err, true /* fromPromise */);
[2022-01-05 11:20:21]           ^
[2022-01-05 11:20:21] 
[2022-01-05 11:20:21] Error: self signed certificate in certificate chain
[2022-01-05 11:20:21]     at TLSSocket.onConnectSecure (node:_tls_wrap:1530:34)
[2022-01-05 11:20:21]     at TLSSocket.emit (node:events:390:28)
[2022-01-05 11:20:21]     at TLSSocket._finishInit (node:_tls_wrap:944:8)
[2022-01-05 11:20:21]     at TLSWrap.ssl.onhandshakedone (node:_tls_wrap:725:12) {
[2022-01-05 11:20:21]   code: 'SELF_SIGNED_CERT_IN_CHAIN'
[2022-01-05 11:20:21] }
[2022-01-05 11:20:21] error Command failed with exit code 1.
[2022-01-05 11:20:21] info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Inspired by: https://www.digitalocean.com/community/questions/mongonetworkerror-self-signed-certificate-in-certificate-chain

This is how I configured my connection:

    connection: {
      connectionString: DATABASE_URL,
      ssl: {
        ca: fs.readFileSync(CA_CERT).toString(),
      },
    },

I don’t want to set rejectUnauthorized: false, I want to use the certificate you provide.

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!