Encrypting Database Connections (TLS)
Cheat sheet · https://pcornel.dk/topic.php?topic=6192
Answer
Encrypting database connections with TLS protects credentials and data in transit; servers present certificates and clients verify them.
Remember
Require TLS on the server (hostssl in pg_hba, require_secure_transport, Force Encryption) and verify certificates on clients (sslmode=verify-full).
First checks
SHOW ssl;— first check for this topicpsql -c "SELECT now(), version();"— PostgreSQL reachable and versionmysql -e "SELECT NOW(), VERSION();"— MariaDB/MySQL reachable and versionsqlcmd -S <server> -Q "SELECT @@VERSION"— SQL Server reachable and version
Commands
SHOW SESSION STATUS LIKE 'Ssl_cipher';
Verify in this order
client → TLS handshake → certificate verified → encrypted session
Where it usually breaks
sslmode=require encrypts but does not verify the server, allowing interception.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6192