How do I find the SSL certificate required for database components in App Platform?

Posted February 23, 2021 1.1k views
Node.jsPostgreSQLDigitalOcean App Platform

I’m trying to deploy a node.js application that interacts with a Postgres database via DO App Platform. I’m using the provided ${db.DATABASE_URL} environment variable and I can see it enforces SSL. I’m getting the UnhandledPromiseRejectionWarning: Error: self signed certificate in certificate chain runtime exception from Node, so that the deploy always fails. I’m using this lib. I’ve tried a few things from other questions here and on StackOverflow, all involving “disabling” SSL, including setting the rejectUnauthorized ssl option to true, all without success. That makes perfect sense because the DB requirement is still there, besides being not what I want (I want the secure deal). When the DB is created separately (for instance, when the app is droplet + DB), it looks like I could download the certificate, so that I could point to it as the lib documentation suggests, but that’s not the case with App Platform. From the plan description, I expect to have SSL everywhere. Is that only for the communication with publicly exposed endpoints?

Any help will be appreciated.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Just found out the docs:

Using code like this and mapping environment variables accordingly worked for me.

Discovered next that the role has no permission to create schemas (so far only used the dev database), so you should create tables right into the default schema.