Using
Suggest editsAfter you have configured all of the Thales Certificates, as stated in the Configuring section, you will be able to use them in conjunction with your EDB Postgres distribution.
Note
It is important to note that this doc is intended for versions 15.2 and above of EDB Postgres Advanced Server and versions 15.2 and above of EDB Postgres Extended Server as these versions support Transparent Data Encryption (TDE).
To implement Thales CipherTrust Manger with your EDB Postgres distribution you must ensure that you have the following downloaded to your system:
- Python
- pykmip
- edb-tde-kmip-client downloaded from your EDB Repos access
All of the .pem
files that you created in the Configuring section, key.pem
, cert.pem
and ca.pem
, need to be copied to the system where your EDB Postgres distribution is installed. For our example, all of the .pem
files and the edb_tde_kmip_client.py
program are in the /tmp/
directory.
Check Prerequisites and Download edb-tde-kmip-client
Ensure that you have the prerequisite software (Python and Pykmip) installed on your system as stated in the Configuring section.
To install the edb-tde-kmip-client on your system assume root
user and issue the install command for edb-tde-kmip-client
. For our example we installed it on a RHEL8 Server so it would be dnf install edb-tde-kmip-client
.
You should receive some output that looks like the following:
Create pykmip.conf File
On your system where you have your EDB Postgres distribution, navigate to the directory where you have saved your
*.pem
files and theedb_tde_kmip_client.py
client.In that directory create a file called
pykmip.conf
and input the following:
- Host
- Port
- Username
- Password
- Keyfile
- Certfile
- Ca_certs
For example:
Note
For more information on the pykmip.conf file and the contents of it you can visit the pykmip documentation.
Create a Key on Thales CipherTrust Manager
There are two ways you can create a key with Thales CipherTrust Manager. You can create one locally with python3 or you an use the Thales CipherTrust Manager UI.
Use one of the two methods listed below to proceed.
Create a Key Locally with python3 on Thales CipherTrust Manager
On your system with your EDB Postgres distribution, login as the superuser of the database to create the key on Thales CipherTrust Manager.
Type
python3
and then input the following, making adjustments per your system setup and directory paths:
Navigate back to Thales CipherTrust Manager, and select
Keys
on the navigation bar.Check that your key, in this case
edbtestkey
, has been created.
Create a Key on Thales CipherTrust Manager UI
You may also create Keys on the Thales CipherTrust Manager UI to use in your database WRAP and UNWRAP commands for encryption.
Login to Thales CipherTrust Manager.
On the main page, select
Keys
from the left bar.Select
Add Key
to create a new key.Give the key an identifiable name, and select the
Key Properties
andKey Usage
boxes per your requirements.Select
Add Key
.After you select
Add Key
, you will be taken to that key's page with specific information.The specific key ID that is needed for your PGDATAKEYWRAPCMD and PGDATAKEYUNWRAPCMD commands is the
ID
which is shown at the top of your key information page.
Verify Encryption and Decryption
To ensure that your key that you created will be able to encrypt and decrypt data, run the following two commands as the superuser on your system where you have your EDB Postgres distribution.
printf secret | python3 /tmp/edb_tde_kmip_client.py encrypt --out-file=test.bin --pykmip-config-file=/tmp/pykmip.conf --key-uid='key_output_here’ --variant=thales
- Location of the KMIP Client: /tmp/edb_tde_kmip_client.py
- Output file: test.bin
- Location of pykmip configuration file: /tmp/pykmip.conf
- Encrypted Key Output: TDE key output
- Variant: Allows for KMIP compatibility with Thales
python3 /tmp/edb_tde_kmip_client.py decrypt --in-file=test.bin --pykmip-config-file=/tmp/pykmip.conf --key-uid='key_output_here' --variant=thales
If this is successful it should produce the output of secret.
Perform initdb for the Database
After you have completed the above steps you will be able to export the PGDATAKEYWRAPCMD and PGDATAKEYUNWRAPCMD to wrap and unwrap your encryption key and initialize your database.
Login to your EDB Postgres distribution system as the database superuser. For our example: enterprisedb user,
sudo su - enterprisedb
.Navigate to the
/bin
directory where your executables live. In our example it is/usr/lib/edb-as/15/bin
.Type:
export PGDATAKEYWRAPCMD='python3 /tmp/edb_tde_kmip_client.py encrypt --pykmip-config-file=/tmp/pykmip.conf --key-uid=key_ouput_here --out-file=%p --variant=thales’
Type:
export PGDATAKEYUNWRAPCMD='python3 /tmp/edb_tde_kmip_client.py decrypt --pykmip-config-file=/tmp/pykmip.conf --key-uid=key_output_here --in-file=%p --variant=thales’
For our example:
Perform your initdb per your database requirements, for example:
./initdb -D dd12 -y
.If all is successful you should get an output that looks like this:
- Start your database and navigate to your
/data
directory to view the postgresql.conf file to ensure that yourdata_encryption_key_unwrap_command
, which you set with yourexport PGDATAUNWRAPCMD
, is present under the Authentication section.
For more information on how TDE is incorporated with EDB Postgres Advanced Server and EDB Postgres Extended Server visit the EDB Transparent Data Encryption documentation.
Could this page be better? Report a problem or suggest an addition!