Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

I have an Express.js app trying to connect to a managed Postgres db. However the connection fails with the following cert error:
ERROR (16): Database connection failed
err: {
"type": "Error",
"message": "self-signed certificate in certificate chain",
"stack":
Error: self-signed certificate in certificate chain
at TLSSocket.onConnectSecure (node:_tls_wrap:1677:34)
at TLSSocket.emit (node:events:519:28)
at TLSSocket._finishInit (node:_tls_wrap:1076:8)
at ssl.onhandshakedone (node:_tls_wrap:862:12)
"code": "SELF_SIGNED_CERT_IN_CHAIN"
}
After some searching it looks like I need to pass in the db’s cert when configuring the connection:
export const db = pgp({
connectionString: DB_CONNECTION_STR,
connect_timeout: 15000, // 15 seconds
ssl: {
rejectUnauthorized: true,
ca: process.env.CA_CERT,
},
});
I also created an environment variable that mapped the value of ${<my-db-name>.CA_CERT} to CA_CERT as described in this article: https://docs.digitalocean.com/products/app-platform/how-to/use-environment-variables/#databases
I replaced <my-db-name> with the name of my managed Postgres instance. When creating the db, I just went with the autogenerated name. This is not my actual db’s name, but it has the same format: db-postgresql-sfo-1000
However, I can’t get the value of the ${db-postgresql-sfo-1000.CA_CERT} expression to evaluate to the correct value. When I write process.env.CA_CERT out to console log I get back the string ‘${db-postgresql-sfo-1000.CA_CERT}’. My guess is that the db name part of the value is not correct. The autogenerated name has hyphens so I tried underscores, but that didn’t help. How can I find what the right value for the ${<my-db-name>.CA_CERT} expression is that I should use?
44698b4d25054ea6a464f4a5215a7b
dolphinnnn
phosphide
xcco3x
Ross
Telmo Valverde
Alexandre Herlinvaux
Lukas Ulrich
72e659fde73744d381097f36c2b3ad
36d56192d3114513857618b22686be
fullammo
StrugglingDeveloper