Hello,
I'm having an issue connecting to a hosted DigitalOcean Postgres server, which requires SSL, but I can't seem to find a way to enable it currently in init() options. Is there a way to do this, or a workaround?
Thanks in advance!
You could probably use driverOptions for that (if you can achieve that in knex, then this allows you to pass additional options to knex).
You could try something like:
MikroORM.init({
// ...
driverOptions: {
connection: { ssl: true },
},
});
There are some issues about this in knex's repository, you should take a look there. One suggests to use environment variable for this:
Workaround which worked for me: set environment variable PGSSLMODE=require. It forces postgres driver to use SSL and it resolved the issue at least in my case. Still waiting for the official patch though.
@DmiPet did it work for you?
Hi @B4nan, thanks so much for the suggestions! Setting environment variable PGSSLMODE=require did the trick 馃憤
@DmiPet did it work for you?
In case anyone else prefers to have their database connection config in the Mikro config, adding these to driverOptions works for me:
{
connection: {
ssl: true
}
}
In case someone comes with a problem on heroku, or getting UnhandledPromiseRejectionWarning: DriverException: self signed certificate for some other reason, here is the fix
driverOptions: {
connection: { ssl: { rejectUnauthorized: false } },
},
Most helpful comment
In case someone comes with a problem on heroku, or getting
UnhandledPromiseRejectionWarning: DriverException: self signed certificatefor some other reason, here is the fix