Search code examples
postgresqlsslloopbackca

How do you connect over SSL to Postgres in Loopback v3


My datasource.json file looks like this...

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "mydb": {
    "host": "mydbhost.db.ondigitalocean.com",
    "port": 25060,
    "url": "",
    "database": "mydb-staging",
    "password": "mypassword",
    "name": "mydb",
    "user": "myuser",
    "connector": "postgresql",
    "ssl" : true
  }
}

But DigitalOcean managed Postgres provides you with a CA file to use.

  1. Where do I put it?
  2. How do i configure LB3 to know about it?

Loopback docs say https://loopback.io/doc/en/lb3/PostgreSQL-connector.html

The PostgreSQL connector uses node-postgres as the driver. For more information about configuration parameters, see node-postgres documentation. https://node-postgres.com/features/ssl

I just don't understand how to setup LB.

When I start my server up i get...

Unhandled rejection error: permission denied for database mydb-staging

Solution

  • If you are using the database services on digital ocean, only the default "doadmin" user can Read and Write on any database, any other added user can only read data.