Chapter 94: HashiCorp Vault and Secrets Management
94.13 Transit — encryption as a service, not a data store
Story (fictional teaching scenario). At a fictional Mysuru shop, Emma from Bristol wants the app to store ciphertext without holding the encryption key itself.
Why
A separate encryption operation can reduce key exposure, but any caller allowed to decrypt can still see plaintext.
What
- Transit engine performs cryptographic operations with keys managed in Vault.
- Plaintext is the input before encryption; ciphertext is encrypted output.
- Base64 is an encoding used for API transport, not encryption.
- Transit does not store application payloads as a KV database; applications store returned ciphertext themselves.
- Key rotation creates a new key version. Existing ciphertext needs retained compatible key versions or an approved migration.
How
-
Separate encrypt-only and decrypt privileges where needed.
-
Send only the intended payload through a protected connection.
-
Store returned ciphertext in the application’s chosen store.
-
Test rotation/restore without destroying old key material.
Example 1: Request and response shape
- Read the command or request.
{"plaintext":"REVNT19PTkxZ"}
- Read the result.
Output (illustrative; NOT executed against Vault)
{"data":{"ciphertext":"vault:v1:ILLUSTRATIVE_NOT_VALID"}}
- Line by line: The plaintext field is base64 for the harmless text DEMO_ONLY. A transit encrypt endpoint such as /v1/transit/encrypt/training-key would use a configured key. The sample ciphertext is invalid placeholder text, not real encryption output. No crypto operation or key creation was run.
Example 2: Do not confuse encoding and encryption
- Read the command or request.
import base64
print(base64.b64decode("REVNT19PTkxZ").decode())
- Read the result.
Output (illustrative; NOT executed against Vault)
DEMO_ONLY
- Line by line: Anyone can reverse base64 without a key. This standard-library decoding is not a Vault integration. A decrypt permission deserves the same care as reading a secret.
Ravindra Bagale's Tip
Base64 hides nothing. Encryption needs protected keys and permissions.
Base64 काहीच लपवत नाही. Encryption ला protected keys आणि permissions लागतात.
Base64 कुछ नहीं छिपाता. Encryption को protected keys और permissions चाहिए.
Did you understand? Let us try it once more.