Secrets Engines · Topic 3 of 4

Choosing a Secrets Engine and the Transit Engine

Vault Associate (003): match a use case to the right secrets engine - KV, database, AWS, cubbyhole or transit - and know what transit is used for.

  • 4 min
In a nutshell
  • Match the verb: store means KV, generate credentials means database or AWS, encrypt means transit.
  • Transit is encryption as a service; Vault does not store the data you send it.
  • The caller keeps the ciphertext and sends it back to Vault to decrypt.

What it is

Vault ships many secrets engines, and the exam expects you to pick the one that fits a described need. The decision comes down to a short question: do you need to store a value, have Vault generate a credential, or have Vault encrypt data for you?

The transit secrets engine is the encryption one. It performs cryptographic operations on data in transit and does not store the data you send it.

Need to store a valueKVNeed a generated loginDatabase or AWSNeed private per token storageCubbyholeNeed data encryptedTransit

How it works

Matching a use case to an engine

Use caseEngineWhy
Store API keys, passwords or config with versionsKV (version 2)Stores and versions static secrets
Short-lived database logins per applicationDatabaseGenerates credentials from roles, with leases
Temporary cloud access keysAWSGenerates IAM credentials dynamically, revoked when the lease expires
Private scratch space for one tokenCubbyholeEach token has its own storage, destroyed when the token expires
Encrypt data held in your own databaseTransitEncryption as a service, Vault does not keep the data
Issue certificates, TOTP codes or SSH accessPKI, TOTP, SSHSpecialized engines for those jobs
Track entities and groups for clientsIdentityMounted by default, cannot be disabled or moved

Read the scenario for the verb. "Store" points to KV, "generate credentials" points to a dynamic engine, and "encrypt" or "protect data in a database" points to transit.

Cubbyhole

Cubbyhole is enabled by default. Data is stored per token, and no token can access another token's cubbyhole. When the token expires, its cubbyhole is destroyed.

It underpins response wrapping, covered on its own page.

What transit does

Applications send plaintext to Vault, Vault encrypts it with a named key and returns ciphertext. The application keeps the ciphertext in its own data store. Vault does not store the data.

ApplicationplaintextTransit engineciphertextApplicationstoresApplication database

This moves key handling from developers to Vault operators. Transit also supports signing and verification, hashes and HMACs, random bytes and data key generation, not only encryption.

Basic transit commands

vault secrets enable transit
vault write -f transit/keys/my-key
vault write transit/encrypt/my-key plaintext=$(echo "my secret data" | base64)
vault write transit/decrypt/my-key ciphertext=vault:v1:...

Plaintext must be base64-encoded before it is sent. The returned ciphertext starts with vault:v1:, where v1 is the key version. Decrypting returns base64 text, which you decode to get the original value.

Keys and rewrapping

Rotating a key creates a new key version, so new ciphertext starts with vault:v2:, while older versions remain available for decryption:

vault write -f transit/keys/my-key/rotate
vault write transit/rewrap/my-key ciphertext=vault:v1:...

Rewrap re-encrypts existing ciphertext under the newest key version without ever exposing the plaintext. The default key type is aes256-gcm96. Key rotation and rewrap are explored further in the Encryption as a service chapter.

Why not KV for this?

KV is a place where data lives, and it stores and versions whatever you write. Transit does not hold your data at all. If an organization has sensitive data sitting unprotected in a database, transit lets the application encrypt it before storing it.

How the exam asks about this

  • "An application keeps customer records unencrypted in its own tables and must protect them." The transit secrets engine.
  • "Which engine generates short-lived database credentials?" The database secrets engine.
  • "Where does transit keep the data it encrypts?" Nowhere; the caller stores the ciphertext.

What to remember for the exam

  • Match the verb: store means KV, generate credentials means database or AWS, encrypt means transit.
  • Transit is encryption as a service; Vault does not store the data you send it.
  • The caller keeps the ciphertext and sends it back to Vault to decrypt.
  • Plaintext sent to transit must be base64-encoded; ciphertext starts with vault:v1: for key version 1.
  • Transit also signs, verifies, creates HMACs and returns random bytes.
  • Cubbyhole is on by default, private to each token, and destroyed when the token expires.
Watch out

Do not choose the KV or cubbyhole engines to "encrypt" data. They store values; only transit performs encryption on data you keep elsewhere.

Common mistakes

Expecting transit to store ciphertext. Vault returns it and forgets the data. Losing the ciphertext in your own store means losing the data.

Sending raw text to transit. The plaintext parameter takes base64. Sending unencoded text is a usage error, not a Vault quirk.

Picking the database engine for "protect data in a database". That engine creates credentials to reach a database. It does not encrypt the rows inside it.

Check yourself

  • Which engine encrypts application data without storing it?

    The transit secrets engine. It returns ciphertext and the application stores that ciphertext itself.

  • A team wants a database login that Vault creates per application. Which engine fits?

    The database secrets engine, which generates credentials from a role and attaches a lease.

  • What does the vault:v1: prefix tell you?

    The value is transit ciphertext returned by Vault, and the application sends it back to Vault to decrypt.

Topic 3 of 4 in Secrets Engines

Test yourself on Secrets Engines

The full HashiCorp Vault Associate 003 question bank has 600 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by HashiCorp. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.