You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 21, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 21, 2020. It is now read-only.
We recently changed the default of the accept_invalid_certs option for postgres connections in quaint to false. Users are reporting that they can't connect because of this (prisma/orm#884 for example). This can be worked around by adding the sslaccept=accept_invalid_certs to the database url in prisma.schema.
Since this appears to be a big issue for some users, I investigated in what ways SSL can be configured when connecting to a postgres database, and what the defaults are in other tools.
For a good overview of the SSL modes supported by postgres clients and their security properties, this blog post is helpful.
Clients
The psql CLI client supports six different sslmode variants. You can read about them in the official docs. Those are the same parameters as libpq. Only the last two levels will verify the server certificates against a trusted CA.
Rails uses libpq with a default sslmode of prefer, so there is no certificate verification.
The docs for node-postgres imply that certificates are verified, but the default settings, or ssl: true will not check the certificate. If you force the client to check the certificate with ssl: { rejectUnauthorized: true }, on DO for example, the connection will be refused. I can share the code to reproduce this if needed.
quaint will by default check the server certificate, which will not work unless you downloaded and configured the certificate correctly on your machine.
Providers
AWS RDS links to root certificates to use with their postgres databases in their docs.
I haven't been able to find docs on what the setup is for DigitalOcean hosted postgres, but it is definitely not signed by a common trusted CA. node-postgres with forced certificate verification returns (node:388342) UnhandledPromiseRejectionWarning: Error: self signed certificate in certificate chain.
Conclusion
Our default settings (without the sslaccept=accept_invalid_certs) is stricter than other clients, and it will fail to connect unless the user sets up the connection with the specific certificate the server uses. For ergonomics, we could couple sslaccept with the passing in of a server certificate file, but at minimum, I think we should flip the default to trust "invalid" certificates, and optionally validate them.
We should probably just go ahead and create a connectors folder with a README.md that links to a postgres.md where you collect this information in a spec like way @tomhoule
Activity
[-]Reseach: postgres SSL setttings[/-][+]Spec our default postgres SSL setttings[/+]tomhoule commentedon Nov 15, 2019
cc @janpio
[-]Spec our default postgres SSL setttings[/-][+]Spec our default postgres SSL settings[/+][-]Spec our default postgres SSL settings[/-][+]Spec our default SSL settings on postgres[/+]schickling commentedon Nov 17, 2019
I agree with your conclusion.
Additionally @nikolasburk should document the various options extensively and provide information on best practices.
janpio commentedon Nov 26, 2019
We should probably just go ahead and create a
connectorsfolder with aREADME.mdthat links to apostgres.mdwhere you collect this information in a spec like way @tomhoule[-]Spec our default SSL settings on postgres[/-][+]Default SSL settings on postgres[/+]tomhoule commentedon Dec 4, 2019
The change was made in quaint, I'll propagate it to the engines today so it will land in preview 18. Specs PR: #346