The Vault Hardware Security Module (HSM) auto-unseal and Seal Wrap features require Vault Enterprise with the Governance & Policy Module.
- Download and install Vault.
- Configure Vault.
- Use Vault.
- Enable the Seal Wrap feature.
- Test the Seal Wrap feature.
- Enable and test the Entropy Augmentation feature.
Download Vault
Download precompiled Vault binaries at https://releases.hashicorp.com/vault/. To download Vault Enterprise binaries, follow the instructions HashiCorp provides Vault customers. This integration requires the Enterprise HSM binary, which is available for testing: https://releases.hashicorp.com/vault/1.7.2+ent.hsm/Install Vault
Perform the following steps to install Vault:1
Run the following command to unzip the downloaded package and then move the vault binary to
/usr/local/bin:Shell
2
Run the following command to set the owner of the Vault binary:
Shell
3
Check that vault is available on the system path.
Shell
4
Run the following command to verify the Vault version:
Shell
5
The vault command features opt-in autocompletion for flags, subcommands, and arguments (where supported).Install autocompletion using the following command:
Shell
6
Run the following command to enable autocompletion:
Shell
7
Run the following command to configure Vault to use the mlock syscall without running the process as root. This operation prevents the system from swapping memory to disk.
Shell
8
Run the following command to create a unique, non-privileged system user to run vault:
Shell
Configure Vault
To configure Vault, perform the following tasks:- Configure systemd.
- Configure Vault settings.
- Configure HSM Auto-unseal and Entropy Augmentation
Configure systemd
Systemd uses documented sane defaults (www.freedesktop.org/software/systemd/man/systemd.directives.html), so you need to set only non-default values in the configuration file.1
Run the following command to create a Vault service file at
/etc/systemd/system/vault.service:Shell
2
Add the following configuration to
vault.service:None
Configure Vault settings
Vault uses documented sane defaults, so you need to set only non-default values in the configuration file.1
Run the following command to create
/etc/vault.d directory:Shell
2
Run the following command to create a Vault configuration file,
vault.hcl:Shell
3
Run the following command to set the ownership of the
/etc/vault.d directory:Shell
4
Run the following command to set the file permissions:
Shell
Configure HSM Auto-unseal and Entropy Augmentation
When you start a Vault server, it normally starts in a sealed state where you must have a quorum of existing unseal keys to unseal it. By integrating Vault with the KMES Series 3, a trusted HSM key provider can automatically unseal the Vault server. To integrate the Vault Enterprise server with a KMES Series 3, the configuration file must define the PKCS11 seal stanza and provide the necessary connection information, as shown in the following example: Example:vault.hcl
None
This guide sets the storage backend to the local file system (
/tmp/vault) to make the verification step easy.| Parameter | Description |
|---|---|
| lib | The path to the PKCS #11 library on the machine where Vault Enterprise is installed. |
| slot | The slot number to use. Set this value to 0 because the FXPKCS11 config file sets the slot to 01 by default. |
| key_label | The label of the key to use. |
| hmac_key_label | The label of the key to use for HMACing |
| generate_key | If no existing key with the label specified by key_label exists at Vault initialization, Vault generates a key. |
For this integration, set the generate\key parameter to
true so that Vault automatically creates the encryption keys that it uses for the Seal Wrap functionality on the KMES. The values set for the key\label and hmac\key\label parameters correspond with the special key label defines that youneed to set in the <CONFIG> section of the fxpkcs11.cfg file).Use Vault
To get started using Vault, perform the following tasks:- Start the Vault server.
- Initialize Vault.
- Access the Vault UI.
Start the Vault server
Perform the following steps to start the Vault server:1
Log in with the vault user.
2
Run the following command to set the PKCS #11 PIN to log in. Use the password of the user you created on the KMES and defined in the
fxpkcs11.cfg file.Shell
You can also set the PKCS #11 PIN in the Vault configuration file (
vault.hcl) with the pin parameter, but we do not recommend that method in a production setting. As a best practice, specify the pin with the VAULT\HSM\PIN environment variable, as shown here, to prevent password exposure if the config file is compromised or stored in an insecure location. If you set it through the environment variable, Vault obfuscates the environment variable after reading it. One caveat: You must reset the VAULT\HSM\PIN environment variable when Vault restarts.3
Run the following command to start the Vault server:
Shell
If the command succeeds, expect output similar to the following example:
None
4
Open a new terminal window for later steps and leave this terminal running where you started the Vault server.
Initialize Vault
Perform the following steps to initialize Vault:1
In the new terminal, run the following command to set the VAULT_ADDR environment variable
Shell
2
Run the following command to check the Vault status:
Shell
The output should be similar to the following example:
None
3
Run the following command to initialize Vault:
Shell
The output should be similar to the following example:
None
4
Run the following command to set the VAULT_TOKEN environment variable value to the generated Initial Root Token value displayed in the terminal output:To interact with Vault, you must provide a valid token.
Shell
Access the Vault UI
Perform the following steps to access the Vault UI:1
Go to
http://localhost:8200 in a web browser.2
Copy and paste the Initial Root Token output from the Vault initialization command into the Token field, and select [ Sign in ].
If the login succeeds, the Vault UI homepage displays.
Enable the Seal Wrap feature
You can enable Seal Wrap by using the following methods:- CLI command
- Web UI
Method 1: CLI command
Perform the following steps to execute the CLI command method:1
To compare seal-wrapped data against unwrapped data, enable key/value v1 secrets engine at two different paths: kv-unwrapped and kv-seal-wrapped.Run the following command to enable k/v v1 without seal wrap at kv-unwrapped:Run the following command to enable k/v v1 with seal wrap by using the -seal-wrap flag when you enable the KV workflow:To enable seal wrap, pass the -seal-wrap flag when you enable a secrets engine
Shell
Shell
2
Run the following command to list the enabled secrets engines with details:
Shell
If the command succeeds, the output is similar the the following example:Notice that the Seal Wrap parameter value is true for kv-seal-wrapped/.
None
Method 2: Web UI
Perform the following steps to execute the Web UI method:1
Open a web browser and launch the Vault UI (for example,
http://127.0.0.1:8200/ui) and then log in.2
Select Enable new engine.
3
Select KV from the list, and then select [ Next ].
4
Enter
kv-unwrapped in the path field and select Version 1 for KV version.5
Return to the Secrets Engines page and select [ Enable Engine ].
6
Select KV from the list, and then select [ Next ].
7
Enter
kv-seal-wrapped in the path field. Select Version 1 for KV version.8
Select [ Method Options ] to expand, and select the check box for Seal Wrap.
9
Select [ Enable Engine ].
Test the Seal Wrap feature
You can test Seal Wrap and view encrypted secrets by using one of the following methods:- CLI command
- Web UI
Method 1: CLI command
Perform the following steps to execute the CLI command method:1
Run the following command to write a secret at kv-unwrapped/unwrapped for testing:
Shell
2
Run the following command to read the path to verify:
Shell
If the command succeeds, the output is similar the the following example:
None
3
Run the following command to write the same secret at kv-seal-wrapped/wrapped for testing:
Shell
4
Run the following command to read the path to verify:
Shell
If the command succeeds, the output is similar the the following example:
None
Use a valid token to write and read secrets the same way, regardless of the seal wrap.
View the encrypted secrets
Remember that you configured the Vault server to use the local file system (/tmp/vault) as its storage backend, as shown in the following example:
None
1
SSH into the machine where the Vault server is running, and check the stored values in the The
/tmp/vault directory:Shell
/tmp/vault/logical directory has two sub-directories. One maps to kv-unwrapped/ and another maps to kv-seal-wrapped/ although you cannot tell by the folder names.2
View the secret at rest. One of the directories maps to
kv-unwrapped/unwrapped.Example of viewing encrypted secrets
The following example demonstrates viewing encrypted secrets:1
Go the first directory:
Shell
2
Run the following command to view its content. The password value is encrypted.
Shell
3
Go to the other directory that maps to
kv-seal-wrapped/wrapped. Then, run the following command to view its content. The password value is encrypted.4
Shell
Secrets are encrypted, but the seal-wrapped value is significantly longer even though both values are the same: my-long-password.
Method 2: Web UI
Perform the following steps to execute the Web UI method:1
Select kv-unwrapped and select [ Create secret ].
2
Enter
unwrapped in the Path for this secret field. Use password in the secret key field and my-longpassword in the value field.3
Select [ Save ].
4
Repeat the same step for kv-seal-wrapped to write the same secret at the
kv-seal-wrapped/wrapped path.5
Select [ Save ].
You can write and read secrets the same way regardless of the seal wrap by using a valid token.
View the encrypted secrets
Remember that you configured the Vault server to use the local file system (/tmp/vault) as its storage backend, as shown in the following example:
None
1
SSH into the machine where the Vault server is running, and check the stored values in the The
/tmp/vault directory.Shell
/tmp/vault/logical directory has two sub-directories. One maps to kv-unwrapped/ and another maps to kv-seal-wrapped/ although you cannot tell by the folder names.2
View the secret at rest. One of the directories maps to kv-unwrapped/unwrapped.
Example of viewing encrypted secrets
The following example demonstrates viewing encrypted secrets:1
Go to the first directory:
Shell
2
Run the following command to view its content. The password value is encrypted.
Shell
3
Another directory maps to kv-seal-wrapped/wrapped.
Shell
4
Run the following command to view its content. The password value is encrypted.
Shell
Secrets are encrypted, but the seal-wrapped value is significantly longer even though both values are the same: my-long-password.
Enable and test the Entropy Augmentation feature
To leverage an external entropy source, you must set the external_entropy_access parameter totrue when you enable a secrets engine or auth method.
Perform the following steps to enable the KMES as the external entropy source on a transit secrets engine:
You must enable the Entropy Augmentation feature through the CLI because we do not support using the Web UI at this time.
1
Run the following command to enable the transit secrets engine with an external entropy source by using the -external-entropy-access flag:
Shell
2
Run the following command to list the enabled secrets engine with -detailed flag:Example output:Notice that the External Entropy Access is set to
Shell
None
true for transit/.3
You can start using the transit secrets engine to encrypt your sensitive data which leverages the KMES as its external entropy source. Regardless, the user experience remains the same as before.
Example workflow
The following example demonstrates the workflow:1
Run the following command to create a new encryption key named orders:
Shell
2
Run the following command to send a base64-encoded string for Vault to encrypt:
Shell
3
Run the following command to test and verify that you can decrypt the string:
Shell
4
Run the following command to decode to get the original data:
Shell

