I have created a Postgresql instance on GCP and enabled SSL, I'm able to connect to the instance using command line just fine however getting error when trying to connect using TypeORM on NodeJS running on localhost (haven't deployed yet, just in case this info helps)
const options = {
type: "postgres",
host: "IP_ADDRESS",
port: 5432,
username: "USERNAME",
password: "PASSWORD",
database: "DATABASE_NAME",
schema: "SCHEMA_NAME",
logging: false,
synchronize: false,
dropSchema: false,
extra: {
ssl: "verify-ca",
},
ssl: {
ca: `-----BEGIN CERTIFICATE-----
THE CERTIFICATE DOWNLOADED FROM GCP
-----END CERTIFICATE-----`,
cert: `-----BEGIN CERTIFICATE-----
THE CERTIFICATE DOWNLOADED FROM GCP
-----END CERTIFICATE-----`,
key: `-----BEGIN RSA PRIVATE KEY-----
THE CERTIFICATE DOWNLOADED FROM GCP
-----END RSA PRIVATE KEY-----`,
},
};
then getting the following error
[Error: root certificate file "/Users/USERNAME/.postgresql/root.crt" does not exist
Either provide the file or change sslmode to disable server certificate verification.
]
well since this is a code that should be deployed later on somewhere on cloud surely i'm not expecting to use local path!
can anyone help me here TYPEORM should use the certificate provided in the options