Ssl – Use Let’s Encrypt certificates with Postgresql

lets-encryptpostgresqlsslssl-certificate

I am trying to setup a remote database connection to a server running postgresql. I am already running nginx on the remote server with a LE certificate. My question is if the postgresql certificate needs to be signed by a CA like let's encrypt or if a self signed certificate would suffice. I am trying to understand what the security risks are when using a self signed cert for my database connection.

Best Answer

A self-signed cert is perfectly fine if you control both ends of the connection. You can provide the client with the CA certificate to verify against.

Public CA certificates exist so that clients who don't already have trusted communication with your server still go "OK, that looks like a legitimate certificate signed by somebody I trust".

The important thing is to use at least sslmode=verify-ca and supply the CA cert as root.crt to the client so it can check the server against it and make sure it's taking to the server it expects. verify-full mode is not necessary if you're using a self-signed cert that only one host has anyway, it's protection against MiTM attacks using legitimate but stolen certificates signed by a trusted CA.

See the manual.