Transparent Data Encryption with External Key Management Across Clouds
Updated: Oct 24
Transparent Data Encryption (TDE) is the control auditors ask about by name, and the one most often half done: the tablespaces are encrypted, but the master key sits in a wallet file on the same server as the data files, and nobody can say who is able to open it. Anyone who copies the server's disks copies both the lock and the key.
This post completes the job. We check the current encryption state, move the master key out of the database host into an external key manager (Oracle Key Vault), set up a safe automatic open at startup, keep Data Guard and backups working, and then look at how the same standard is applied on OCI, Oracle Database@Azure and Amazon RDS for Oracle.
The Use Case
A customer database must be encrypted at rest with keys the DBAs do not hold on the database server. Every use of the key must be auditable, and the same standard must apply to the copies running in OCI and Azure. TDE encrypts the data, a keystore holds the master key, and an external key manager holds that keystore so that file-system access alone can never open the data.
Environment used in this runbook
Database: Oracle Database 19c (19.22), container database PROD with one PDB, SALESPDB
Host: Oracle Linux 8, single instance with a physical standby PRODSB
Key manager: Oracle Key Vault 21.8, two-node multi-master cluster
Encrypted tablespaces: APP_DATA, APP_IDX, APP_LOB in SALESPDB
Starting point: a password-protected software keystore (wallet file) with auto-login
How the Pieces Fit
Tablespace keys encrypt the data blocks. Data files, redo, undo, temp segments and RMAN backups of encrypted tablespaces all stay encrypted, while SQL sees clear text.
The TDE master encryption key wraps (encrypts) the tablespace keys. It never leaves the keystore in clear text.
The keystore is either a software keystore (an ewallet.p12 file) or an external keystore: Oracle Key Vault, OCI Vault, Azure Key Vault or a hardware security module (HSM).
In united mode (the default for a CDB), the CDB root manages one keystore that holds the master keys of every PDB.
Step 1: Check the Current Keystore and Encryption State
Before changing anything, record where the keys live today, whether the keystore is open, and what is encrypted. You will compare against this after the migration.
SQL |
sqlplus / as sysdba
SHOW PARAMETER wallet_root SHOW PARAMETER tde_configuration
SELECT con_id, wrl_type, status, wallet_type, keystore_mode FROM v$encryption_wallet ORDER BY con_id; |
Expected output |
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------------
wallet_root string /u01/app/oracle/admin/PROD/wallet
NAME TYPE VALUE
------------------------------------ ----------- ---------------------------------
tde_configuration string KEYSTORE_CONFIGURATION=FILE
CON_ID WRL_TYPE STATUS WALLET_TYPE KEYSTORE_MODE
---------- -------- ------ ----------- -------------
1 FILE OPEN AUTOLOGIN NONE
2 FILE OPEN AUTOLOGIN UNITED
3 FILE OPEN AUTOLOGIN UNITEDWhat to expect: WALLET_ROOT points to the keystore directory and TDE_CONFIGURATION says FILE, so the keys are in a wallet on this host. WALLET_TYPE AUTOLOGIN means the wallet opens without a password: anyone who copies the cwallet.sso file together with the data files can read the data. That is the gap we close.
Step 2: List the Encrypted Tablespaces and the Master Keys
Connect to the PDB and confirm which tablespaces are encrypted, with which algorithm, and which master keys exist.
SQL |
ALTER SESSION SET CONTAINER = salespdb;
SELECT t.name AS tablespace_name, e.encryptionalg, e.status FROM v$encrypted_tablespaces e JOIN v$tablespace t ON t.ts# = e.ts# AND t.con_id = e.con_id ORDER BY t.name;
SELECT key_id, TO_CHAR(creation_time,'YYYY-MM-DD') AS created, activating_pdbname, key_use FROM v$encryption_keys; |
Expected output |
TABLESPACE_NAME ENCRYPTIONALG STATUS
--------------- ------------- ----------
APP_DATA AES256 NORMAL
APP_IDX AES256 NORMAL
APP_LOB AES256 NORMAL
SYSAUX AES256 NORMAL
SYSTEM AES256 NORMAL
UNDOTBS1 AES256 NORMAL
KEY_ID CREATED ACTIVATING_PDBNAME KEY_USE
------------------------------------------------------ ---------- ------------------ ----------
AQ8fAQUo7k9Fv3s1x0lq1VQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2025-11-03 SALESPDB TDE IN PDBWhat to expect: All tablespaces show AES256 and NORMAL (fully encrypted). If an application tablespace is missing, encrypt it first with ALTER TABLESPACE ... ENCRYPTION ONLINE USING 'AES256' ENCRYPT. There is one active master key for the PDB. Keep this KEY_ID: after the migration the same key must be visible through Oracle Key Vault.
Step 3: Back Up the Software Keystore
Every key operation in this post is done WITH BACKUP, but take an extra, independent copy of the wallet directory now. If anything goes wrong during the migration, this copy is what opens the database.
Shell |
cd /u01/app/oracle/admin/PROD/wallet ls -l tde/
tar czf /secure/backup/PROD_tde_wallet_20260806.tgz tde/ sha256sum /secure/backup/PROD_tde_wallet_20260806.tgz |
Expected output |
total 12
-rw-------. 1 oracle oinstall 4021 Nov 3 2025 cwallet.sso
-rw-------. 1 oracle oinstall 3976 Nov 3 2025 ewallet.p12
-rw-------. 1 oracle oinstall 2555 Nov 3 2025 ewallet_2025110309122281.p12
5b0e2c61f4d3d7a0e5c1a3b9a1f0c7e8d2b4a6c8e0f1a3b5c7d9e1f3a5b7c9d1 /secure/backup/PROD_tde_wallet_20260806.tgzWhat this does: It saves ewallet.p12 (the password-protected keystore), cwallet.sso (the auto-login copy) and the earlier backup. Store the archive and the keystore password in a location that the database backups cannot reach, such as the security team's password vault. A lost keystore means a lost database.
Step 4: Enrol the Database with Oracle Key Vault
In the Oracle Key Vault web console, the key administrator creates an endpoint for the database, places it in a wallet (a group of keys) such as PROD_TDE, and issues a one-time enrolment token. The DBA then downloads the endpoint software with that token and installs it under WALLET_ROOT/okv, which is where the database looks for it.
Shell |
# Download okvclient.jar with the enrolment token (Oracle Key Vault console > Endpoints > Enroll), # then install it into WALLET_ROOT/okv mkdir -p /u01/app/oracle/admin/PROD/wallet/okv java -jar okvclient.jar -d /u01/app/oracle/admin/PROD/wallet/okv -v
# Test the connection to the Key Vault cluster /u01/app/oracle/admin/PROD/wallet/okv/bin/okvutil list |
Expected output |
Oracle Key Vault endpoint software installed successfully.
Enter new Key Vault endpoint password ("d" for auto-login): ********
Confirm new Key Vault endpoint password: ********
Unique ID Type Identifier
600D0743-01D9-4F2F-BF6F-C9E8AC74FF2A Template Default template for PROD_EPWhat to expect: The installer asks for an endpoint password: choose a strong one, because it becomes the keystore password the database uses (do not choose auto-login here). okvutil list connects to the Key Vault cluster and shows the endpoint's default template. If it fails with a connection error, check that ports 5695 and 5696 (KMIP) are open from the database host to both Key Vault nodes.
Tip: Upload the existing wallet to the Key Vault as an additional backup before migrating: okvutil upload -t WALLET -l /u01/app/oracle/admin/PROD/wallet/tde -g PROD_TDE. The keys are then recoverable from Key Vault even if the local archive is lost.
Step 5: Switch TDE_CONFIGURATION to Key Vault
The value OKV|FILE tells the database that its master key will live in Oracle Key Vault, while the local file keystore is still kept as a reverse-migration path and to read old backups. The parameter is dynamic.
SQL |
ALTER SYSTEM SET tde_configuration = 'KEYSTORE_CONFIGURATION=OKV|FILE' SCOPE = BOTH SID = '*';
SELECT con_id, wrl_type, status, wallet_type FROM v$encryption_wallet WHERE con_id = 1; |
Expected output |
System altered.
CON_ID WRL_TYPE STATUS WALLET_TYPE
---------- -------- ------------------ -----------
1 FILE OPEN AUTOLOGIN
1 OKV CLOSED UNKNOWNWhat to expect: Two rows per container now: the FILE keystore (still open) and the OKV keystore (closed, because it holds no master key yet). Nothing has changed for the application so far.
Step 6: Migrate the Master Keys into Oracle Key Vault
This is the actual move. The database creates new master keys inside Key Vault and re-wraps every tablespace key with them. The data itself is not re-encrypted, so the operation takes seconds and the database stays open. In united mode, run it once in the CDB root with CONTAINER = ALL.
SQL |
ALTER SESSION SET CONTAINER = cdb$root;
ADMINISTER KEY MANAGEMENT SET ENCRYPTION KEY IDENTIFIED BY "OkvEndpoint#Pwd2026" MIGRATE USING "Wallet#Pwd2025" WITH BACKUP CONTAINER = ALL;
SELECT con_id, wrl_type, status, wallet_type, wallet_order FROM v$encryption_wallet ORDER BY con_id, wallet_order; |
Expected output |
keystore altered.
CON_ID WRL_TYPE STATUS WALLET_TYPE WALLET_ORDER
---------- -------- ------ ----------- ------------
1 OKV OPEN OKV PRIMARY
1 FILE OPEN AUTOLOGIN SECONDARY
2 OKV OPEN OKV PRIMARY
2 FILE OPEN AUTOLOGIN SECONDARY
3 OKV OPEN OKV PRIMARY
3 FILE OPEN AUTOLOGIN SECONDARYWhat this does: IDENTIFIED BY is the Key Vault endpoint password from Step 4 and MIGRATE USING is the old wallet password. OKV is now the PRIMARY keystore in every container: new master keys are created there. The FILE keystore becomes SECONDARY and is used only to read objects encrypted with old keys, such as old backups.
Step 7: Open the Key Vault Keystore Automatically at Startup
Without an auto-login setting, the database would need the endpoint password typed in after every restart (ORA-28365: wallet is not open). The safe pattern is to store that password, not the keys, in a small local auto-login keystore in WALLET_ROOT/tde_seps. The keys themselves stay in Key Vault, and Key Vault can revoke the endpoint at any time.
SQL |
ADMINISTER KEY MANAGEMENT ADD SECRET 'OkvEndpoint#Pwd2026' FOR CLIENT 'OKV_PASSWORD' TO LOCAL AUTO_LOGIN KEYSTORE '/u01/app/oracle/admin/PROD/wallet/tde_seps';
-- From now on, key commands use the stored password ADMINISTER KEY MANAGEMENT SET KEYSTORE CLOSE IDENTIFIED BY EXTERNAL STORE CONTAINER = ALL; ADMINISTER KEY MANAGEMENT SET KEYSTORE OPEN IDENTIFIED BY EXTERNAL STORE CONTAINER = ALL; |
Expected output |
keystore altered.
keystore altered.
keystore altered.What to expect: After a restart, the database reads the endpoint password from tde_seps, connects to Key Vault and opens the keystore without any manual step. Now remove the old cwallet.sso from WALLET_ROOT/tde (keep ewallet.p12 for the secondary keystore), so that the master keys are no longer readable from the host without a password.
Step 8: Prove That the Keys Now Live in Key Vault
Restart the database and confirm the keystore opens from Key Vault. Then rotate the master key once, which proves that Key Vault is answering write requests as well as reads.
SQL |
SHUTDOWN IMMEDIATE STARTUP
SELECT con_id, wrl_type, status, wallet_type, wallet_order FROM v$encryption_wallet WHERE wrl_type = 'OKV';
ADMINISTER KEY MANAGEMENT SET KEY FORCE KEYSTORE IDENTIFIED BY EXTERNAL STORE WITH BACKUP CONTAINER = ALL; |
Expected output |
CON_ID WRL_TYPE STATUS WALLET_TYPE WALLET_ORDER
---------- -------- ------ ----------- ------------
1 OKV OPEN OKV PRIMARY
2 OKV OPEN OKV PRIMARY
3 OKV OPEN OKV PRIMARY
keystore altered.What to expect: The OKV keystore is OPEN in every container straight after startup. The rotation succeeds and the new key appears in the Key Vault console under the PROD_TDE wallet, with an audit record showing which endpoint requested it. As a final test, stop the Key Vault endpoint (or block the KMIP ports briefly in a test copy): the database can no longer open the keystore, which is exactly the control the auditors asked for.
Step 9: Keep the Data Guard Standby Working
A standby must be able to decrypt the redo it receives, so it needs the same master keys before the primary uses a new key. With Key Vault the cleanest design is to enrol the standby as its own endpoint and give it access to the same PROD_TDE wallet.
SQL |
-- On the standby PRODSB, after installing its own endpoint software in WALLET_ROOT/okv ALTER SYSTEM SET tde_configuration = 'KEYSTORE_CONFIGURATION=OKV|FILE' SCOPE = BOTH;
ADMINISTER KEY MANAGEMENT ADD SECRET 'OkvStandby#Pwd2026' FOR CLIENT 'OKV_PASSWORD' TO LOCAL AUTO_LOGIN KEYSTORE '/u01/app/oracle/admin/PRODSB/wallet/tde_seps';
SELECT database_role, open_mode FROM v$database; SELECT con_id, wrl_type, status FROM v$encryption_wallet WHERE wrl_type = 'OKV'; |
Expected output |
System altered.
keystore altered.
DATABASE_ROLE OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY MOUNTED
CON_ID WRL_TYPE STATUS
---------- -------- ------
1 OKV OPENWhat this does: The standby reads the same master keys from Key Vault, so redo encrypted with a newly rotated key is applied without errors. On the primary, check that apply is not lagging after the next rotation (V$DATAGUARD_STATS). If you skip this step, the first rotation on the primary stops redo apply on the standby with ORA-28374.
Step 10: Operate It
Rotate the master key on a schedule (for example every 12 months, or after any staff change in the security team) with ADMINISTER KEY MANAGEMENT SET KEY ... WITH BACKUP. Rotation only re-wraps the tablespace keys, so it is fast.
Back up Key Vault itself to a remote destination from its console, and test a Key Vault restore once a year. The Key Vault cluster is now part of the database's recovery path.
RMAN backups of encrypted tablespaces stay encrypted. Restoring them on another host requires access to the same Key Vault wallet, which is a feature: a stolen backup is useless.
Data Pump exports are clear text unless you add ENCRYPTION=ALL with ENCRYPTION_MODE=PASSWORD or TRANSPARENT.
Across Clouds
OCI Base Database and Exadata Database Service: every database is TDE-encrypted by default with an Oracle-managed wallet. To hold the keys in your own tenancy, switch the database to customer-managed keys in OCI Vault, from the console (Database details > Manage encryption key) or the CLI shown below.
Oracle Database@Azure: Exadata Database Service can store TDE master keys in Azure Key Vault (Standard, Premium or Managed HSM). An identity connector links the VM cluster to the vault, and existing databases can be switched from the file wallet to Azure Key Vault. Managed HSM needs private connectivity.
Oracle Database@Google Cloud and Oracle Database@AWS: the OCI Vault option applies, and integrations with the host cloud's key service are being added. Check the current service documentation for what is supported today.
Amazon RDS for Oracle: TDE is an option in the option group, with the keystore managed by RDS. Storage encryption uses AWS KMS keys you control. If policy requires the TDE master key itself to be in a key manager you operate, run the database on EC2 with Oracle Key Vault, or use an OCI service.
Self-managed databases on any cloud VM: follow Steps 1 to 10 exactly. Place the Key Vault nodes in the same cloud region as the databases, because every keystore open goes to Key Vault.
Shell |
# OCI: move an existing database to a customer-managed key in OCI Vault oci db database migrate-vault-key \ --database-id ocid1.database.oc1.eu-frankfurt-1.example \ --vault-id ocid1.vault.oc1.eu-frankfurt-1.example \ --kms-key-id ocid1.key.oc1.eu-frankfurt-1.example
# Later: rotate to a new key version oci db database rotate-vault-key --database-id ocid1.database.oc1.eu-frankfurt-1.example |
What this does: The first command changes the database's key management from Oracle-managed to your OCI Vault key. Your tenancy's IAM policies then control who can use the key, and disabling the key makes the database unreadable. The second command rotates to a new key version.
Pitfalls
ORA-28365 after a restart: the external store password is missing or wrong, or Key Vault is unreachable. Check tde_seps and the network before anything else.
Never skip WITH BACKUP. A key operation without a backup is one disk failure away from losing the database.
Keep the old wallet as the secondary keystore until every backup taken before the migration has expired.
Prove the encryption is real: restore a backup on a host that has no access to Key Vault. If the data opens, something is not encrypted.
Summary
Encrypting tablespaces is only half of TDE. The other half is getting the master key off the database host. Record the current state, back up the wallet, enrol the database with Oracle Key Vault, set TDE_CONFIGURATION to OKV|FILE, migrate with one ADMINISTER KEY MANAGEMENT command, and open the keystore automatically through a stored password rather than an auto-login wallet. Enrol the standby with the same wallet before the first rotation. On OCI and Oracle Database@Azure the same result comes from OCI Vault or Azure Key Vault, and on RDS from the managed TDE option, with its limits understood.
Comments