This is the multi-page printable view of this section.
Key management
- 1: Key management overview
- 2: Keyring file configuration
- 3: Vault configuration
- 4: Using OpenBao as a key provider
- 5: KMIP configuration
- 6: Thales KMIP server configuration
- 7: Fortanix KMIP server configuration
- 8: Akeyless KMIP server configuration
- 9: Default principal key configuration
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
1 - Key management overview
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
This overview retains an older qualification of Vault KMIP. The 2.2.2 release notes explicitly announce Vault Enterprise KMIP support; consult those notes for the version-specific status. See site errata.
In production environments, storing encryption keys locally on the PostgreSQL server can introduce security risks. To enhance security, pg_tde supports integration with external Key Management Systems (KMS) through a Global Key Provider interface.
This section describes how you can configure pg_tde to use the local and external key providers.
To use an external KMS with pg_tde:
- Configure a Key Provider
- Set the Global Principal Key
While key files may be acceptable for local or testing environments, KMS integration is the recommended approach for production deployments.
When using HashiCorp Vault, KV v2 is the recommended and supported integration method.
The KMIP engine in Vault is not a validated configuration for pg_tde and is not recommended for production deployments.
Do not rotate encryption keys while a backup is running. This may result in an inconsistent backup and restore failure. This applies to all backup tools.
Schedule key rotations outside backup windows. After rotating keys, take a new full backup.
For more details, see Limitations of pg_tde.
pg_tde has been tested with the following key providers:
| KMS Provider | Description | Documentation |
|---|---|---|
| KMIP | Standard Key Management Interoperability Protocol. | Configure KMIP → |
| Vault | HashiCorp Vault integration (KV v2 API). | Configure Vault → |
| Fortanix | Fortanix DSM key management. | Configure Fortanix → |
| Thales | Thales CipherTrust Manager and DSM. | Configure Thales → |
| OpenBao | Community fork of Vault, supporting KV v2. | Configure OpenBao → |
| Akeyless | A cloud-based secrets management platform for securely storing and accessing credentials and encryption keys. | Configure Akeyless → |
| Keyring file (not recommended) | Local key file for dev/test only. | Configure keyring file → |
2 - Keyring file configuration
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
The inspection example now uses the table it creates and the current database key-info function. See site errata.
This setup is intended for development and stores the keys, unencrypted, in a data file you specify.
While keyring files may be acceptable for local or testing environments, proper KMS providers are the recommended approach for production deployments.
You can configure key providers either at the database level (for development and testing) or at the global level (for production).
The steps below provide an example on how to add a database-scoped key provider:
Create a database-scoped file key provider (
file-keyringin this example) in the/tmp/pg_tde_test_local_keyring.perfile:Create a key (
my_default_keyin this example) inside the newly createdfile-keyringprovider:Set the key (
my_default_key) from the key provider (file-keyring):TipYou can check the current database key information (such as the date and time of creation). Run:
Now, create a table using tde_heap:
The newly created table is encrypted with the database key you have set (
my_default_key).TipTo check if your created table is encrypted with tde_heap, run:
If
Access method: tde_heap, then your table is encrypted.Example outputpostgres=# \d+ customer_table Table “public.customer_table” Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description ——–+———+———–+———-+———+———+————-+————–+————- a | integer | | | | plain | | | Access method: tde_heap
Further reading
Next, for production deployments, configure a global principal key using a proper KMS provider.
Alternatively, you can skip directly to validating encryption with pg_tde or configuring WAL encryption.
You can also review the available pg_tde functions in Functions.
3 - Vault configuration
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
You can configure pg_tde to use HashiCorp Vault as a global key provider for managing encryption keys securely. Both the open source and enterprise editions are supported.
Configure Vault with pg_tde in Docker
This example setup describes how to run HashiCorp Vault and Percona PostgreSQL with pg_tde side by side using Docker, configure Vault policies, and connect it as a global key provider for TDE encryption.
For production deployments, follow your organization’s security standards.
1. Create the docker-compose.yaml file
The following docker-compose.yaml file is an example on how to run both Vault and PostgreSQL with a shared secrets volume:
2. Enable the KV v2 secrets engine
In the Vault container, enable a KV v2 storage engine for pg_tde:
This creates a tde/ mount for storing encrypted keys.
If you are using Vault Enterprise namespaces, you don’t need a separate
namespace parameter when configuring pg_tde.
You can include the namespace directly in the mount path. For example:
This is equivalent to configuring a namespace separately and works with both:
- Vault OSS
- Vault Enterprise (with namespaces)
3. Create a Vault policy for pg_tde
Define a Vault policy that grants pg_tde access to read, write, and list keys.
This allows pg_tde to:
- read, create, and update encryption keys
- list and access metadata for the
tde/path
If you encounter the following error:
Ensure your Vault policy includes the following path:
This allows pg_tde to read the mount metadata from Vault.
4. Create an Authentication Method and Token
Enable the AppRole authentication method:
Generate a token associated with the tde-policy:
Example output:
5. Share the token with PostgreSQL
Copy the generated token into the shared secrets directory (shared secrets volume) so PostgreSQL can use it:
You can access this file in PostgreSQL at /etc/postgresql/secrets/vault_token.txt.
6. Register Vault as a global key provider in PostgreSQL
In the PostgreSQL container, connect pg_tde to Vault using:
7. Create and set the global master key
Create the global master key:
Then set it:
8. Test encryption with a sample table
Create a sample table:
Then insert data into the table:
Query the table and confirm that the encryption is functioning:
Example global key provider usage
Parameter descriptions
provider-nameis the name to identify this key providersecret_token_pathis a path to the file that contains an access token with read and write access to the above mount pointurlis the URL of the Vault servermountis the mount point where the keyring should store the keys- [optional]
ca_pathis the path of the CA file used for SSL verification
The following example is for testing purposes only. Use secure tokens and proper SSL validation in production environments:
For more information on related functions, see Function Reference.
Required permissions
The PostgreSQL instance requires the following Vault API capabilities to manage and read encryption keys:
sys/mounts/<mount>/*- read permissions<mount>/data/*- create, read permissions<mount>/metadata/*- list permissions
For more information on Vault permissions, see the following documentation.
Next steps
4 - Using OpenBao as a key provider
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
You can configure pg_tde to use OpenBao as a global key provider for managing encryption keys securely.
This guide assumes that your OpenBao server is already set up and accessible. OpenBao configuration is outside the scope of this document, see OpenBao’s official documentation for more information.
Example usage
To register an OpenBao server as a global key provider:
Parameter descriptions
provider-nameis the name to identify this key providersecret_token_pathis a path to the file that contains an access token with read and write access to the above mount pointurlis the URL of the OpenBao servermountis the mount point where the keyring should store the keys- [optional]
ca_pathis the path of the CA file used for SSL verification - [optional]
namespaceis the namespace within the OpenBao server. Read more about the namespace support in OpenBao` (NOTE: You can use a namespace without ca_path. In this case, specify NULL as the ca_path value)
The following example is for testing purposes only. Use secure tokens and proper SSL validation in production environments:
For more information on related functions, see the link below:
Percona pg_tde Function Reference
Next steps
5 - KMIP configuration
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
This overview retains an older qualification of Vault KMIP. The 2.2.2 release notes explicitly announce Vault Enterprise KMIP support; consult those notes for the version-specific status. See site errata.
To use a Key Management Interoperability Protocol (KMIP) server with pg_tde, you must configure it as a global key provider. This setup enables pg_tde to securely fetch and manage encryption keys from a centralized key management appliance.
When using HashiCorp Vault as a KMIP server, this configuration is not a validated deployment model for pg_tde and is not recommended for production use.
For Vault-based key management, use the KV v2 integration instead.
You need the root certificate of the KMIP server and a client key/certificate pair with permissions to create and read keys on the server.
For testing purposes, you can use a Eviden KMS server, which enables easy certificate generation and basic KMIP behavior. If you’re using a production-grade KMIP server, ensure you obtain valid, trusted certificates from the key management appliance.
Example usage
Parameter descriptions
provider-nameis the name of the provider. You can specify any name, it’s for you to identify the providerkmip-IPis the IP address of a domain name of the KMIP serverportis the port to communicate with the KMIP server. Typically used port is 5696server-certificateis the path to the certificate file for the KMIP serverclient_certis the path to the client certificate.client_keyis the path to the client key.
The following example is for testing purposes only.
For more information on related functions, see the link below:
Percona pg_tde Function Reference
Next steps
6 - Thales KMIP server configuration
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
pg_tde is compatible with the Thales CipherTrust Manager via the KMIP protocol. For a full setup guide, see the Thales documentation.
For more information on adding or modifying the provider, see the Adding or modifying KMIP providers topic.
7 - Fortanix KMIP server configuration
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
pg_tde is compatible with Fortanix Data Security Manager (DSM) via the KMIP protocol. For a full setup guide, see the Fortanix KMIP documentation here.
For more information on adding or modifying the provider, see the Adding or modifying KMIP providers topic.
8 - Akeyless KMIP server configuration
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
pg_tde is compatible with the Akeyless CipherTrust Manager via the KMIP protocol. For a full setup guide, see the Akeyless documentation .
For more information on adding or modifying the provider, see the Add or modify KMIP providers topic.
Next steps
9 - Default principal key configuration
This is the Percona pg_tde 2.3.0 manual. For the paired build, backup tools and major upgrades, see PG TDE on Mimus.
You can configure a default principal key for the server using a global key provider. This key is used by all databases that do not have their own encryption keys configured.
Configuring the default principal key is a multi-step process that uses the following functions:
- pg_tde_add_global_key_provider_
() adds a global key provider - pg_tde_create_key_using_global_key_provider() creates a principal key at a global key provider
- pg_tde_set_default_key_using_global_key_provider() sets the default principal key and rotates the internal encryption key if one is already configured
Add a global key provider
To add a global key provider, see the Key provider management topic.
Create a default principal key
The sample output below is for demonstration purposes only. Be sure to replace the key name and provider with your actual values.
To create a global principal key, run:
Set a default principal key
To set a default principal key, run:
Parameter description
key-nameis the name under which the principal key is stored in the provider.global_vault_provideris the name of the global key provider you previously configured.
If no error is reported, the action completed successfully.
How key generation works
The key material (actual cryptographic key) is auto-generated by pg_tde and stored securely by the configured provider.
This process sets the default principal key for the entire server. Any database without a key explicitly configured will fall back to this key.
Next steps
To confirm that encryption is working as expected, follow the validation steps: