-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6354 from EnterpriseDB/release/2024-12-17a
Release: 2024-12-17a
- Loading branch information
Showing
5 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
product_docs/docs/tde/15/enabling/enabling_key_wrapper.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
title: "Protect the data encryption key on an existing TDE cluster" | ||
description: Learn how to enable a mechanism to protect the data encryption key on an existing TDE-enabled database cluster. | ||
--- | ||
|
||
If you want to enable key wrapping on TDE-enabled database clusters where key wrapping was previously disabled, update the encryption settings in the `postgresql.conf` file. | ||
|
||
## Context | ||
|
||
When you create a TDE-enabled database cluster, `initdb` generates a data encryption key and stores it in `pg_encryption/key.bin`. Since this file is stored in plaintext, TDE requires an additional mechanism to [secure the data encryption key](../secure_key/). You normally configure the protection of the key as you initialize your TDE-enabled database cluster. | ||
|
||
However, you can chose to [disable key wrapping](../secure_key/disabling_key) for your data encryption key. Although this setup is not recommended, you might have chosen to leave your key unprotected to facilitate managing the cluster for testing or demo purposes. | ||
|
||
If you disabled key wrapping, but later decide to enable a mechanism that secures your encryption key, you can enable it at a later time, by updating the encryption settings in the `postgresql.conf` file. | ||
|
||
## Enable key wrapping with a passphrase | ||
|
||
This example walks you through adding a passphrase-based protection mechanism or key wrapping to your data encryption key (`key.bin`). | ||
|
||
1. Store the passphrase in a file accessible by initdb named `pass.bin`: | ||
|
||
!!!important | ||
This example stores the passphrase in plaintext, a method you should only use for testing or demonstration purposes. In production environments, don't store your passphrase in a file. See [Using a passphrase](../secure_key/passphrase) for alternative methods. | ||
!!! | ||
|
||
``` | ||
echo "<passphrase>" > /var/lib/postgresql/pass.bin | ||
``` | ||
|
||
1. Use OpenSSL to encrypt the existing `key.bin` data encryption key with the stored passphrase and save the encrypted file as `key.bin.WRAP`: | ||
|
||
``` | ||
cat $PGDATA/pg_encryption/key.bin | openssl enc -e -aes-128-cbc -pbkdf2 -pass file:/var/lib/postgresql/pass.bin -out $PGDATA/pg_encryption/key.bin.WRAP | ||
``` | ||
|
||
1. Create a backup of the unwrapped data encryption key named `key.bin.NOWRAP` in case you need to roll back to the original configuration: | ||
|
||
``` | ||
cp $PGDATA/pg_encryption/key.bin $PGDATA/pg_encryption/key.bin.NOWRAP | ||
``` | ||
|
||
1. Replace the existing data encryption key with the wrapped version: | ||
|
||
``` | ||
cp $PGDATA/pg_encryption/key.bin.WRAP $PGDATA/pg_encryption/key.bin | ||
``` | ||
|
||
1. Create a backup of the existing configuration file named `postgresql.conf.NOWRAP` in case you need to roll back to the original configuration: | ||
|
||
``` | ||
cp $PGDATA/postgresql.conf $PGDATA/postgresql.conf.NOWRAP | ||
``` | ||
|
||
1. Modify the `data_encryption_key_unwrap_command` value of the `postgresql.conf` file with the new command: | ||
|
||
``` | ||
sed -i "s|data_encryption_key_unwrap_command.*|data_encryption_key_unwrap_command = 'openssl enc -d -aes-128-cbc -pbkdf2 -pass file:/var/lib/postgresql/pass.bin -in \"%p\"'|" $PGDATA/postgresql.conf | ||
``` | ||
|
||
1. Create a backup of the modified `postgresql.conf` file that includes the key wrapping named `postgresql.conf.WRAP`: | ||
|
||
``` | ||
cp $PGDATA/postgresql.conf $PGDATA/postgresql.conf.WRAP | ||
``` | ||
|
||
1. Restart your database cluster to populate the updated data encryption key configuration: | ||
|
||
``` | ||
pg_ctl start | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cb3f515
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Published on https://edb-docs-staging.netlify.app as production
π Deployed on https://6761a294c9501688db6e0707--edb-docs-staging.netlify.app
cb3f515
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π Published on https://edb-docs.netlify.app as production
π Deployed on https://6761a3ced32a1214be21c4c5--edb-docs.netlify.app