Connecting to a Postgres database using SSL #10834
cryptogohan
started this conversation in
General
Replies: 1 comment
-
I'm using heroku have the same issue. Posted abut it here: eveningkid/denodb#356 One change with the above script it's When I run it I get:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This'll be a bit longer and is all about making sure Deno happily connects to Postgres databases using SSL, which I assume, the maintainers of Deno care about. I love Deno, but got burned quite a bit, ~6 or so hours sunk, when you think you're done, trying to deploy your neatly dockerized project, but with several major cloud providers, Deno has trouble with each when trying to connect to Postgres. Now insecure DB connections actually seem quite common in hindsight, Digital Ocean being the exception here, forcing SSL, when most cloud providers have virtual private networks making this not such a big deal, but still, having Deno be able to make SSL Postgres connections I'd consider far from a luxury and almost a necessity for wide adoption. So let's see what I've found and if people are interested let's improve the road a bit for those who will come after shall we 😄 !
AWS
Works! You download the AWS
global-bundle.pem
from a random doc page, but with thecertFile
property on the newstartTls
this works. The most popular pg driver for Deno will need an update but I'm happy to PR that.Google Cloud
This one doesn't work. I have a working example running with node. The difference is that Google Cloud doesn't attach DNS to their SQL instances, just IPs, to use TLS we need a hostname. On the node side we can pass a
servername
like shown here, with Deno we have no such option. No option means no hostname for the certificate authority to have authority over and that seems the end of the exercise. Google Cloud uses private connections between most services anyway so I'm not sure this one is even worth fixing, but perhaps a contributor feels different.Working Node Example
Digital Ocean
It's a similar set-up with a DNS attached and a cert available like AWS but in this case rustls throws an error:
InvalidData: invalid certificate: BadDER
, I'll go ask over there why this certificate is judged invalid.Heroku
I know someone had issues with Heroku, looks like they use an AWS DB, so I assume that'll work with cert passing.
Aside
Just use a non-SSL connection if you get stuck.. that's what I would've done had it not been for Digital Ocean disallowing this and the main Postgres driver trying and crashing whilst attempting to upgrade the connection. I'll go open a corresponding issue over there to make sure non-SSL connections work at least, now that I deeply understand the intricacies of establishing SSL connections with Postgres.
Beta Was this translation helpful? Give feedback.
All reactions