Choosing a key protection mechanism

When you initialize a new cluster with initdb while enabling TDE, you must choose how to protect the data encryption key that TDE generates.

Data encryption key

TDE generates a data encryption key when you initialize the database cluster with initdb, and stores it in a file, pg_encryption/key.bin, under the data directory. This file contains several keys used for different purposes at runtime; the data key itself is a single sequence of random bytes within it.

If you don't perform any further action, this file contains the key in plaintext, which isn't secure. Anyone with access to the encrypted data directory has access to the plaintext key, which defeats the purpose of encryption.

Choosing a mechanism to protect the key

To secure the data encryption key, you must specify a wrap and an unwrap command that provides TDE with a data encryption protection mechanism, either as initdb options or as environment variables. You can set this parameter only at server start.

See Protecting the data encryption key to compare your options before choosing one:

Each option's page shows the exact wrap and unwrap commands to use for that mechanism, both as environment variables and as initdb command-line arguments.

Using a passphrase

Learn how to secure your encryption key with a passphrase.

Using a key store

Learn how to secure your encryption key with a KMS key.

Disabling the key wrapping

Learn how to omit using a wrapping key.


Could this page be better? Report a problem or suggest an addition!