Skip to content

Commit fb53637

Browse files
Merge pull request #6342 from EnterpriseDB/transparent_data_encryption/streamlining_docs
TDE: improvements and fixes for DOCS-1147
2 parents 8da1d07 + 4f48893 commit fb53637

File tree

9 files changed

+45
-28
lines changed

9 files changed

+45
-28
lines changed

product_docs/docs/tde/15/enabling/enabling_tde.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ Create a new EDB Postgres Advanced Server cluster with TDE enabled.
1212

1313
## Worked example
1414

15-
This example uses EDB Postgres Advanced Server 15 running on a Linux platform. It uses OpenSSL to define the passphrase to wrap and unwrap the generated data encryption key.
15+
This example uses EDB Postgres Advanced Server 16 running on a Linux platform. It uses OpenSSL to define the passphrase to wrap and unwrap the generated data encryption key.
1616

1717
1. Set the data encryption key (wrap) and decryption (unwrap) environment variables:
1818

1919
```shell
20-
export PGDATAKEYWRAPCMD='openssl enc -e -aes-128-cbc -pass pass:<password> -out %p'
21-
export PGDATAKEYUNWRAPCMD='openssl enc -d -aes-128-cbc -pass pass:<password> -in %p'
20+
export PGDATAKEYWRAPCMD='openssl enc -e -aes-128-cbc -pbkdf2 -pass pass:<password> -out "%p"'
21+
export PGDATAKEYUNWRAPCMD='openssl enc -d -aes-128-cbc -pbkdf2 -pass pass:<password> -in "%p"'
2222
```
2323

2424
!!!note
@@ -28,21 +28,21 @@ This example uses EDB Postgres Advanced Server 15 running on a Linux platform. I
2828
1. Initialize the cluster using `initdb` with encryption enabled. This command sets the `data_encryption_key_unwrap_command` parameter in the `postgresql.conf` file.
2929

3030
```shell
31-
/usr/edb/as15/bin/initdb --data-encryption -D /var/lib/edb/as15/data
31+
/usr/edb/as16/bin/initdb --data-encryption -D /var/lib/edb/as16/data
3232
```
3333

3434
1. Start the cluster:
3535

3636
```shell
37-
/usr/edb/as15/bin/pg_ctl -D /var/lib/edb/as15/data start
37+
/usr/edb/as16/bin/pg_ctl -D /var/lib/edb/as16/data start
3838
```
3939

4040
1. Run grep on `postgresql.conf` to verify the setting of `data_encryption_key_unwrap_command`:
4141

4242
```shell
43-
grep data_encryption_key_unwrap_command /var/lib/edb/as15/data/postgresql.conf
43+
grep data_encryption_key_unwrap_command /var/lib/edb/as16/data/postgresql.conf
4444
__OUTPUT__
45-
data_encryption_key_unwrap_command = 'openssl enc -d -aes-128-cbc -pass pass:<password> -in %p'
45+
data_encryption_key_unwrap_command = 'openssl enc -d -aes-128-cbc -pass pass:<password> -in "%p"'
4646
```
4747

4848
1. [Verify that data encryption is enabled](verifying_tde).

product_docs/docs/tde/15/enabling/enabling_tde_epas.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ Use [pg_dumpall](https://www.postgresql.org/docs/current/app-pg-dumpall.html), [
5454
1. Set environment variables to export the `wrap` and `unwrap` commands:
5555

5656
```
57-
export PGDATAKEYWRAPCMD='openssl enc -e -aes-128-cbc -pass pass:ok -out %p'
58-
export PGDATAKEYUNWRAPCMD='openssl enc -d -aes-128-cbc -pass pass:ok -in %p'
57+
export PGDATAKEYWRAPCMD='openssl enc -e -aes-128-cbc -pbkdf2 -pass pass:ok -out "%p"'
58+
export PGDATAKEYUNWRAPCMD='openssl enc -d -aes-128-cbc -pbkdf2 -pass pass:ok -in "%p"'
5959
```
6060

6161
!!!note
@@ -109,7 +109,8 @@ Use [pg_dumpall](https://www.postgresql.org/docs/current/app-pg-dumpall.html), [
109109
Include the `--copy-by-block` option.
110110

111111
```
112-
/usr/lib/edb-as/16/bin/pg_upgrade -b /usr/lib/edb-as/16/bin -B /usr/lib/edb-as/16/bin -d /var/lib/edb-as/16/non-TDE -D /var/lib/edb-as/16/TDE --copy-by-block --check
112+
/usr/lib/edb-as/16/bin/pg_upgrade -b /usr/lib/edb-as/16/bin -B /usr/lib/edb-as/16/bin \
113+
-d /var/lib/edb-as/16/non-TDE -D /var/lib/edb-as/16/TDE --copy-by-block --check
113114
```
114115

115116
!!!note
@@ -118,7 +119,8 @@ Use [pg_dumpall](https://www.postgresql.org/docs/current/app-pg-dumpall.html), [
118119
1. To copy data from the source server to the target server, run the `pg_upgrade` command in normal mode:
119120

120121
```
121-
/usr/lib/edb-as/16/bin/pg_upgrade -b /usr/lib/edb-as/16/bin -B /usr/lib/edb-as/16/bin -d /var/lib/edb-as/16/non-TDE -D /var/lib/edb-as/16/TDE --copy-by-block
122+
/usr/lib/edb-as/16/bin/pg_upgrade -b /usr/lib/edb-as/16/bin -B /usr/lib/edb-as/16/bin \
123+
-d /var/lib/edb-as/16/non-TDE -D /var/lib/edb-as/16/TDE --copy-by-block
122124
```
123125

124126
1. Restart the encrypted server:

product_docs/docs/tde/15/enabling/postgres_to_extended.mdx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ This example upgrades a PostgreSQL 16 instance to EDB Postgres Extended Server 1
5454
1. Set environment variables to export the `wrap` and `unwrap` commands:
5555

5656
```
57-
export PGDATAKEYWRAPCMD='openssl enc -e -aes-128-cbc -pass pass:ok -out %p'
58-
export PGDATAKEYUNWRAPCMD='openssl enc -d -aes-128-cbc -pass pass:ok -in %p'
57+
export PGDATAKEYWRAPCMD='openssl enc -e -aes-128-cbc -pbkdf2 -pass pass:ok -out "%p"'
58+
export PGDATAKEYUNWRAPCMD='openssl enc -d -aes-128-cbc -pbkdf2 -pass pass:ok -in "%p"'
5959
```
6060

6161
!!!note
@@ -109,7 +109,8 @@ This example upgrades a PostgreSQL 16 instance to EDB Postgres Extended Server 1
109109
Include the `--copy-by-block` option.
110110

111111
```
112-
/usr/lib/edb-pge/16/bin/pg_upgrade -b /usr/lib/postgresql/16/bin -B /usr/lib/edb-pge/16/bin -d /var/lib/postgresql/16/non-TDE -D /var/lib/edb-pge/16/TDE --copy-by-block --check
112+
/usr/lib/edb-pge/16/bin/pg_upgrade -b /usr/lib/postgresql/16/bin -B /usr/lib/edb-pge/16/bin \
113+
-d /var/lib/postgresql/16/non-TDE -D /var/lib/edb-pge/16/TDE --copy-by-block --check
113114
```
114115

115116
!!!note
@@ -118,7 +119,8 @@ This example upgrades a PostgreSQL 16 instance to EDB Postgres Extended Server 1
118119
1. To copy data from the source server to the target server, run the `pg_upgrade` command in normal mode:
119120

120121
```
121-
/usr/lib/edb-pge/16/bin/pg_upgrade -b /usr/lib/postgresql/16/bin -B /usr/lib/edb-pge/16/bin -d /var/lib/postgresql/16/non-TDE -D /var/lib/edb-pge/16/TDE --copy-by-block
122+
/usr/lib/edb-pge/16/bin/pg_upgrade -b /usr/lib/postgresql/16/bin -B /usr/lib/edb-pge/16/bin \
123+
-d /var/lib/postgresql/16/non-TDE -D /var/lib/edb-pge/16/TDE --copy-by-block
122124
```
123125

124126
1. Restart the encrypted server:

product_docs/docs/tde/15/encrypted_files/wal_files.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ Alternatively, you can set the `PGDATAKEYUNWRAPCMD` environment variable before
4141
This example uses `pg_waldump` to display the WAL log of an encrypted cluster that uses `openssl` to wrap the data encryption key:
4242

4343
```
44-
pg_waldump --data-encryption --key-file-name=pg_encryption/key.bin --key-unwrap-command='openssl enc -d -aes-128-cbc -pass pass:<passphrase> -in %p'
44+
pg_waldump --data-encryption --key-file-name=pg_encryption/key.bin \
45+
--key-unwrap-command='openssl enc -d -aes-128-cbc -pbkdf2 -pass pass:<passphrase> -in "%p"'
4546
```
4647

4748
## Resetting a corrupt TDE-encrypted WAL file
@@ -59,5 +60,5 @@ Alternatively, you can set the `PGDATAKEYUNWRAPCMD` environment variable before
5960
This example uses `pg_resetwal` to reset a corrupt encrypted WAL log of an encrypted cluster that uses `openssl` to wrap the data encryption key:
6061

6162
```
62-
pg_resetwal --key-unwrap-command='openssl enc -d -aes-128-cbc -pass pass:<passphrase> -in %p'
63+
pg_resetwal --key-unwrap-command='openssl enc -d -aes-128-cbc -pbkdf2 -pass pass:<passphrase> -in" "%p"'
6364
```

product_docs/docs/tde/15/initdb_tde_options.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ Adds transparent data encryption when initializing a database server.
1111

1212
### Supported values
1313

14-
You can optionally specify an AES key length. Valid values are 128 and 256. The default is 128.
14+
You can optionally specify an AES key length in the form of `--data-encryption[=KEYLEN]`.
15+
16+
Valid values are 128 and 256. The default is 128.
1517

1618
## Option: `--key-wrap-command=<command>`
1719

product_docs/docs/tde/15/secure_key/disabling_key.mdx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ description: Learn how to omit using a wrapping key.
44
deepToc: true
55
---
66

7-
If you don't want key wrapping, for example for testing, then you must set the wrap and unwrap commands to the special value `-`.
7+
If you don't want key wrapping, for example, for testing purposes, you can use either one of the following options to disable key wrapping:
88

9-
This setting specifies to use the key from the file without further processing. This approach differs from not setting a wrap or unwrap command at all and from setting either or both to an empty string. Having no wrap or unwrap command set when TDE is used leaves your data encryption key unsecured and results in a fatal error when running an affected utility program.
9+
- You can set the wrap and unwrap commands to the special value `-` when initializing the cluster with `initdb`. For example, with the flags `--key-wrap-command=-` and `--key-unwrap-command=-`.
10+
11+
- Or you can disable key wrapping when initializing the cluster with `initdb` by adding the flag `--no-key-wrap`.
12+
13+
With either one of the configurations, TDE generates encryption key files, but leaves them unprotected.
14+
15+
For `intidb --data-encryption` to run successfully, you have to either specify a wrapping/unwrapping command, set a fallback environment variable with wrapping/unwrapping commands, or disable key wrapping with the one of the previous mechanisms. Otherwise, the creation of an encrypted database cluster will fail.

product_docs/docs/tde/15/secure_key/index.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ You must make the commands available to the TDE database server so it can wrap a
4848
<details><summary>Example</summary>
4949

5050
```shell
51-
PGDATAKEYWRAPCMD='openssl enc -e -aes128-wrap -pbkdf2 -out "%p"'
52-
PGDATAKEYUNWRAPCMD='openssl enc -d -aes128-wrap -pbkdf2 -in "%p"'
51+
PGDATAKEYWRAPCMD='openssl enc -e -aes-128-cbc -pbkdf2 -out "%p"'
52+
PGDATAKEYUNWRAPCMD='openssl enc -d -aes-128-cbc -pbkdf2 -in "%p"'
5353
export PGDATAKEYWRAPCMD PGDATAKEYUNWRAPCMD
5454
#After these variables are set, you can initialize the server:
5555
initdb --data-encryption -D /var/lib/edb/as16/data
@@ -63,7 +63,9 @@ You must make the commands available to the TDE database server so it can wrap a
6363
<details><summary>Example</summary>
6464

6565
```shell
66-
initdb --data-encryption -D /var/lib/edb/as16/data --key-wrap-command='openssl enc -e -aes128-wrap -pbkdf2 -out "%p"' --key-unwrap-command='openssl enc -d -aes128-wrap -pbkdf2 -in "%p"'
66+
initdb --data-encryption -D /var/lib/edb/as16/data \
67+
--key-wrap-command='openssl enc -e -aes-128-cbc -pbkdf2 -out "%p"' \
68+
--key-unwrap-command='openssl enc -d -aes-128-cbc -pbkdf2 -in "%p"'
6769
```
6870

6971
</details>

product_docs/docs/tde/15/secure_key/key_store.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ vault write -f transit/keys/pg-tde-master-1
8383
Use the `vault write` command with the `pg-tde-master-1` key to wrap and unwrap the data encryption key:
8484

8585
```
86-
PGDATAKEYWRAPCMD='base64 | vault write -field=ciphertext transit/encrypt/pg-tde-master-1 plaintext=- > %p'
87-
PGDATAKEYUNWRAPCMD='vault write -field=plaintext transit/decrypt/pg-tde-master-1 ciphertext=- < %p | base64 -d'
86+
PGDATAKEYWRAPCMD='base64 | vault write -field=ciphertext transit/encrypt/pg-tde-master-1 plaintext=- > "%p"'
87+
PGDATAKEYUNWRAPCMD='vault write -field=plaintext transit/decrypt/pg-tde-master-1 ciphertext=- < "%p" | base64 -d'
8888
```
8989

9090
## Thales CipherTrust Manager example

product_docs/docs/tde/15/secure_key/passphrase.mdx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ description: Learn how to secure your encryption key with a passphrase.
66
You can protect the data key with a passphrase using the OpenSSL command line utility. The following is an example that sets up this protection:
77

88
```shell
9-
initdb -D datadir -y --key-wrap-command='openssl enc -e -aes-128-cbc -pbkdf2 -out "%p"' --key-unwrap-command='openssl enc -d -aes-128-cbc -pbkdf2 -in "%p"'
9+
initdb -D datadir --data-encryption \
10+
--key-wrap-command='openssl enc -e -aes-128-cbc -pbkdf2 -out "%p"' \
11+
--key-unwrap-command='openssl enc -d -aes-128-cbc -pbkdf2 -in "%p"'
1012
```
1113

1214
This example wraps the randomly generated data key (done internally by initdb) by encrypting it with the AES-128-CBC (AESKW) algorithm. The encryption uses a key derived from a passphrase with the PBKDF2 key derivation function and a randomly generated salt. The terminal prompts for the passphrase. (See the openssl-enc manual page for details about these options. Available options vary across versions.) The initdb utility replaces `%p` with the name of the file that stores the wrapped key.
@@ -30,8 +32,8 @@ Key unwrap commands that prompt for passwords on the terminal don't work when th
3032
For example, for systemd, you can use `systemd-ask-password`:
3133

3234
```
33-
PGDATAKEYWRAPCMD="bash -c 'openssl enc -e -aes-128-cbc -pbkdf2 -out %p -pass file:<(sudo systemd-ask-password --no-tty)'"
34-
PGDATAKEYUNWRAPCMD="bash -c 'openssl enc -d -aes-128-cbc -pbkdf2 -in %p -pass file:<(sudo systemd-ask-password --no-tty)'"
35+
PGDATAKEYWRAPCMD="bash -c 'openssl enc -e -aes-128-cbc -pbkdf2 -out "%p" -pass file:<(sudo systemd-ask-password --no-tty)'"
36+
PGDATAKEYUNWRAPCMD="bash -c 'openssl enc -d -aes-128-cbc -pbkdf2 -in "%p" -pass file:<(sudo systemd-ask-password --no-tty)'"
3537
```
3638

3739
You also need an entry like in `/etc/sudoers`:

0 commit comments

Comments
 (0)