Enable Encryption secures PostgreSQL data in-transit and at-rest by configuring SSL/TLS and using cryptographic functions such as pgcrypto.
Prevent eavesdropping on client–server traffic and protect sensitive columns (e.g., credit-card numbers) from unauthorized reads. Compliance frameworks like PCI-DSS require both transport and data-at-rest encryption.
PostgreSQL offers SSL/TLS for transport encryption and the pgcrypto extension for column-level encryption.Disk-level encryption (LUKS, AWS KMS, etc.) is handled outside PostgreSQL.
Generate server.crt and server.key, copy them to $PGDATA, set permissions to 600, and add ssl = on plus ssl_cert_file / ssl_key_file paths in postgresql.conf. Restart PostgreSQL to activate.
Distribute the CA certificate and connect with sslmode = verify-full to ensure hostname validation.
Install pgcrypto (CREATE EXTENSION pgcrypto;).Use pgp_sym_encrypt to store cipher text and pgp_sym_decrypt to read it. Store keys in a vault, not in code.
Yes—SSL secures the wire, pgcrypto secures data at rest. They are complementary.
Use a Hardware Security Module (HSM) or cloud KMS.Rotate keys periodically, store key IDs not raw keys in the database, and audit decrypt events.
Run SHOW ssl; to confirm on. Query pg_extension for pgcrypto. Review pg_settings where name LIKE 'ssl%'.
Skipping server restart after changing ssl = on. Storing encryption keys in source code. See details below.
.
SSL handshake adds minimal overhead; session reuse keeps impact under 5% for typical workloads.
PostgreSQL lacks transparent table-level encryption; use disk encryption or third-party extensions for full-table protection.
pgcrypto uses OpenSSL; compliance depends on your OpenSSL build and configuration. Check your platform’s FIPS validation.