The Vault Hardware Security Module (HSM) auto-unseal and Seal Wrap features require Vault Enterprise with the Governance & Policy module.
- Download Vault.
- Install Vault.
- Configure systemd.
- Configure Vault.
- Configure HSM Auto-unseal and Entropy Augmentation.
- Start using the Vault server.
- Enable and test the Seal Wrap feature.
- Enable and test the Entropy Augmentation feature.
Download Vault
You can download precompiled Vault binaries at https://releases.hashicorp.com/vault/. Download Vault Enterprise binaries by following the instructions available to HashiCorp Vault customers. This integration requires the Enterprise HSM binary. You can use the following link for testing: https://releases.hashicorp.com/vault/Install Vault
Perform the following steps to install Vault:The vault command features opt-in autocompletion for flags, subcommands, and arguments, where supported.
Shell
Give Vault the ability to use the mlock syscall without running the process as root. The mlock syscall prevents memory from being swapped to disk.
Shell
Configure systemd
Systemd uses documented sane defaults ( www.freedesktop.org/software/systemd/man/systemd.directives.html), so you must set only non-default values in the configuration file.Configure Vault
Vault uses documented sane defaults, so you need to set only non-default values in the configuration file.Configure HSM Auto-unseal and Entropy Augmentation
When a Vault server is started, it normally starts in a sealed state where a quorum of existing unseal keys is required to unseal it. By integrating Vault with the CryptoHub, a trusted HSM key provider can automatically unseal the Vault server. To integrate the Vault Enterprise server with a CryptoHub, the configuration file must define the PKCS11 seal stanza ( www.vaultproject.io/docs/configuration/seal/pkcs11.html) providing necessary connection information. Example:vault.hcl
Text
This guide sets the storage backend to the local file system (
/tmp/vault) to simplify the verification step.- lib: Path to the PKCS #11 library on the machine where Vault Enterprise is installed.
- slot: The slot number to use (this should be set to “0” because “0” is the slot that is set by default in the FXPKCS11 config file).
- key_label: Defines the label of the key to use.
- hmac_key_label: Defines the label of the key to use for HMACing.
- generate_key: If no existing key with the label specified by
key_labelcan be found at Vault initialization time, 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 CryptoHub. The values set for the key_label and hmac_key_label parameters correspond with the special key label defines that you must set in the <CONFIG> section of the fxpkcs11.cfg file.Start using the Vault Server
Perform the following tasks to start using the Vault server:- Start the Vault server.
- Initialize Vault.
- Access the Vault UI.
Start the Vault server
Perform the following steps to start the Vault server:Next, set the PKCS #11 PIN for login with the following command (this is the CryptoHub identity password configured inside the
<CRYPTO-OPR-PASS> tag 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 this in a production environment. As a best practice, specify the PIN with the VAULT\HSM\PIN environment variable, as shown here. This prevents the password from being exposed if the config file is compromised or stored in an unsecured location. If set through the environment variable, Vault obfuscates the environment variable after reading it. The one caveat is that you must reset the VAULT\HSM\PIN environment variable if you restart Vault.Now, start the Vault server with the following command.
Shell
If the command succeeded, you should see something similar to the following output:
None
Initialize Vault
Perform the following steps to initialize Vault:Access the Vault UI
Perform the following steps to access the Vault UI:Go tohttp://localhost:8200 in a web browser.
Enable and test the Seal Wrap feature
Perform the following tasks:- Enable Seal Wrap.
- Test the Seal Wrap feature.
Enable Seal Wrap
Select one of the following methods to enable Seal Wrap and follow the instructions:CLI command
To compare seal-wrapped data against unwrapped data, enable the key/value v1 secrets engine at two different paths:
kv-unwrapped and kv-seal-wrapped.- Enable k/v v1 without seal wrap at
kv-unwrapped. - 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.
Web UI
Open a web browser, launch the Vault UI (http://127.0.0.1:8200/ui), and then log in.
Test the Seal Wrap feature
Select one of the following methods to test Seal Wrap and follow the instructions:CLI command
Perform the following steps to test the Seal Wrap feature:
Perform the following steps to view the encrypted secrets:
Remember that you configured the Vault server to use the same local file as the system (
/tmp/vault) as its storage backend in this example:None
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.Web UI
Perform the following steps to test the Seal Wrap feature:Enter “unwrapped” in the Path for this secret field, “password” in the secret key field, and “my-long-password” in the value field.
Repeat the same step for kv-seal-wrapped to write the same secret at the
kv-seal-wrapped/wrapped path.Remember that you configured the Vault server to use the same local file as the system (
/tmp/vault) as its storage backend in this example:None
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.Enable and test the Entropy Augmentation feature
To leverage an external entropy source, theexternal_entropy_access parameter must be set to true when you enable a secrets engine or auth method.
This step enables the CryptoHub as the external entropy source on a transit secrets engine.
The Entropy Augmentation feature must be enabled through the command-line interface (CLI). Currently, we do not support enabling Entropy Augmentation through the Web UI.
Execute the following command to enable
transit secrets engine with external entropy source by using the -external-entropy-access flag.Shell
List the enabled secrets engine with the -detailed flag.Notice that the External Entropy Access is set to true for
Shell
transit/.You can start using the 2. Send a base64-encoded string to be encrypted by Vault.3. Now, test to verify that you can decrypt.4. Decode to get the original data.
transit secrets engine to encrypt your sensitive data, which leverages the CryptoHub as its external entropy source. Regardless, the user experience remains the same as before.Example:1. Create a new encryption key named orders.Shell
Shell
Shell
Shell
When the external entropy access is enabled, you need connectivity to the CryptoHub. If the CryptoHub becomes unreachable for any reason, the
transit secrets engine fails to generate new keys or rotate the existing keys. The error is similar to the following example:None

