This is a cache of https://developer.ibm.com/tutorials/awb-deploy-vault-securely-confidential-environment/. It is a snapshot of the page as it appeared on 2025-11-15T02:38:00.980+0000.
Deploying Vault securely in a confidential environment - IBM Developer
Deploying Vault securely in a confidential environment
Learn how to build and run a IBM Vault Self-Managed for Z and LinuxONE container in the IBM Hyper Protect Container Runtime with HSM-based auto-unsealing using PKCS#11
IBM Vault Self-Managed for Z and LinuxONE (previously known as Hashicorp Vault for s390x) helps manage secrets like encryption keys, API tokens, and database passwords in a secure, central place. But this also makes it a key target for attackers.
Vault stores secrets on disk using a Master Key. This key can be secured further with a Key Encryption Key (KEK) from a Hardware Security Module (HSM), allowing features like auto-unseal and seal wrapping.
Vault’s security can be made stronger by protecting the server itself, so that sensitive data is not exposed through insider threats or memory dumps.
When Vault runs inside a Confidential Computing environment such as Hyper Protect Virtual Server (HPVS), it’s protected from memory inspection—even by someone with super-user access. This is possible because HPVS uses the Hyper Protect Container Runtime (HPCR) to secure workloads, as shown below:
Besides protecting memory, HPVS ensures the containerized workload is built on an immutable contract and can be encrypted to keep it confidential.
This tutorial is divided into three parts:
Build a container image of Vault that accepts configuration through BASE64-encoded environment variables.
Set up Vault to run inside HPVS.
Use the Vault instance in HPVS with an external HSM (via GREP11) for the sealing and unsealing process.
Prerequisites
Basic knowledge of HPVS (setup steps like logging and contract definition are not covered here).
Basic knowledge of Vault.
Podman will be used instead of Docker (using Containerfile to build images and podman play YAML files instead of docker-compose.yaml).
Access to an s390x server or VSI on LinuxONE to build images (cross-building for s390x is out of scope for this tutorial).
Access to a container registry (this tutorial uses IBM Cloud Container Registry (ICR) - us.icr.io).
IBM Vault Self Managed on IBM Z and LinuxONE can be downloaded from Passport Advantage - PID 5900BP2. Update the Containerfile based on the method you choose.
Access to a GREP11 container with PKCS11 capability (similar to Hyper Protect Crypto Service on IBM Cloud with EP11 endpoints).
Part 1. Create a containerized Vault image that accepts BASE64-encoded environment variables
HPVS requires containerized workloads. In this step, we'll build a Vault image that reads configuration files created from BASE64 encoded environment variables. This makes it easy to reuse the image and HPVS contract without rebuilding the image every time configs change.
Build and push the image:
a. Log in to your s390x Linux VSI. Create and move into an empty directory. This will be your working folder.
b. Copy the vault_script.sh into this directory. This script generates Vault config files from BASE64 env vars and starts Vault.
c. Copy the Containerfile into the same directory. It creates a /vault/data directory for RAFT, downloads the latest Vault binary for s390x, and copies vault_script.sh into the image.
Replace {registry}, {image-name}, and {version} with your values. (See sample output).
e. Push the image using:
podman push {registry}/{image-name}:{version}
Copy codeCopied!
Get the image URL with SHA-256 digest:
You’ll need the image’s SHA-256 digest for HPVS. Check the registry for the image’s digest. It will look like this:
{registry}/{image-name}@sha256:{sha256sum}
Copy codeCopied!
Example for IBM Cloud Container Registry (ICR): ICR Sample
Get the ENV variables:
a. Copy the Vault config file vault-conf.hcl into your working directory. This file sets up Vault to enable the UI, listen on http://0.0.0.0:8200, use the license file /vault/license.hclic, and use raft for storage at /vault/data.
Note: In a real deployment, especially in production, you should use TLS/HTTPS with signed certificates. This tutorial does not cover that setup.
Part 3. Configure Vault to use external HSM (via GREP11) for seal/unseal
To use GREP11 with Vault for sealing and unsealing, you’ll need a running GREP11 container with a database backend. To connect, gather the following:
Hostname, IP, or URL
Port (default: 9876)
CA certificate: grep11-ca.pem
Client certificate: grep11-client.pem (signed by the above CA)
Client key: grep11-client.key
Note: If you don’t have access to an on-prem GREP11 container, you can use IBM Cloud Hyper Protect Crypto Services (HPCS). In that case, the grep11client.yaml configuration file (used by the PKCS#11 library) will be different. Refer to the HPCS documentation for setup details.
Build Vault image with HSM and PKCS#11 support.
a. Log in to your s390x Linux VSI, create a new empty directory, and switch into it. This will be your working directory.
b. Add the new vault_script.sh to this directory. This script will generate config files from base64-encoded environment variables (for Vault and the PKCS#11 library) and start Vault.
c. Add the new Containerfile to the same directory. It is similar to the previous steps, but it also downloads the latest Vault HSM binary, downloads version 2.6.8 of the PKCS#11 library for s390x (update the link if a newer version is available), and copies the new vault_script.sh to the image (make sure the script is in the same directory).
These values will differ each time. You can find more logging details.
c. Login and test Vault operations.
Login to Vault (as per the above sample):
./vault login token=hvs.PniWzjqonUqK3q6wQkfUdTKB
Copy codeCopied!
Success! You are now authenticated. The token information displayed below
is already stored inthetoken helper. You do NOT need to run "vault login"
again. Future Vault requests will automatically use this token.
Key Value
--- -----token hvs.PniWzjqonUqK3q6wQkfUdTKB
token_accessor gL7k67gSck0PbFEEsIgIANwy
token_duration ∞
token_renewable false
token_policies ["root"]
identity_policies []
policies ["root"]
Copy codeCopied!
You should see a success message confirming you're authenticated.
Now you can test basic operations such as vault operator seal, vault operator unseal, and vault status.
Vault with HSM should auto-unseal after a restart.
To test, seal Vault if it’s not already sealed, restart the HPVS guest. Once it’s back up, run:
./vault status
Copy codeCopied!
Key Value--- -----
Seal Type pkcs11
Recovery Seal Type shamir
Initialized true
Sealed false
Total Recovery Shares 5
Threshold 3Version1.19.1+ent.hsm
Build Date2025-03-06T18:16:09Z
StorageType raft
ClusterName vault-cluster-c8c01c44
Cluster ID bcdf2373-95e7-3170-10d6-c45a5997b082
Removed FromClusterfalse
HA Enabled true
HA Cluster https://127.0.0.1:8201/
HA Mode active
Active Since 2025-03-20T13:33:07.34429041Z
Raft CommittedIndex179579
Raft Applied Index179579
Last WAL 68842
Copy codeCopied!
You should see Sealed is false and Seal Type is pkcs11, confirming it auto-unsealed.
About cookies on this siteOur websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising.For more information, please review your cookie preferences options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.