Encryption enforcement
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
For pg_tde, encryption enforcement ensures that only encrypted storage is allowed for specific operations, tables, or the entire database. It prevents the accidental creation of unencrypted tables or indexes in environments where encryption is required for compliance, security, or policy enforcement.
What does enforcement do?
When enabled, encryption enforcement:
- Prevents creation of unencrypted tables or indexes
- Enforces consistent encryption usage across tenants, databases, or users
- Can be scoped globally, per database, or per role
Enforce encryption usage
Use the following techniques to enforce the secure use of pg_tde.
1. Enforce encryption across the server
To enforce encryption cluster-wide, set the pg_tde.enforce_encryption variable in postgresql.conf:
Only superusers can set or change this variable.
This ensures that no user, including superusers, can create unencrypted tables. Superusers can however explicitly override the variable in their session.
2. Enforce encryption for a specific database
To apply encryption enforcement only within a specific database, run:
This ensures encryption is enforced only when connected to that database.
3. Enforce encryption for a specific user
You can also enforce encryption on a per-user basis, run:
This ensures that the user example_user cannot create unencrypted tables, regardless of which database they connect to.
Override enforcement for trusted sessions
Superusers can override the variable at the session level:
This allows temporary creation of unencrypted tables in special cases, such as:
- Loading trusted, public reference datasets
- Benchmarking and test environments
- Migration staging before re-encryption
While superusers can disable enforcement in their session, they must do so explicitly. Enforcement defaults remain active to protect from accidental misconfiguration.