Skip to content

Master keys and the HSM

Two master keys protect what the Platform holds: one seals the HSM simulator’s LMK, the other wraps the vault’s keys. Neither is stored in a database or in a backup, so a backup is useless without them, and a lost key can’t be recovered.

By default the keys come from .env, which puts them in the containers’ environment. They can come from files instead, as Docker and Kubernetes hand secrets to containers, and as cloud secret stores are mounted.

  • Docker Compose: put each key in a file readable only by the services’ user:

    openssl rand -hex 32 > hsm-master.key && chown 10001 hsm-master.key && chmod 400 hsm-master.key

    In .env, leave HSM_MASTER_KEY and VAULT_MASTER_KEY unset, set HSM_MASTER_KEY_PATH and VAULT_MASTER_KEY_PATH to the files, and start with docker compose -f compose.yaml -f compose.keyfiles.yaml up -d.

  • Kubernetes or another orchestrator: mount the secrets and set ISO8583SIM_PLATFORM_HSM_MASTER_KEY_FILE and ISO8583SIM_PLATFORM_VAULT_MASTER_KEY_FILE to the mounted paths.

Give each key one source: a service with both the key and its file set refuses to start. Moving a key from .env to a file changes nothing else; it’s the same key.

With the service stopped, and the current key still where it reads it:

docker compose stop vault
docker compose run --rm vault iso8583sim-vault rotate /path/to/new.key

then put the new key where the vault reads it, and start it again. Only the data keys are re-wrapped, in one transaction. The HSM simulator’s key rotates the same way, with iso8583sim-hsm rotate.

  • The HSM simulator’s: the sealed LMK can’t be opened. Delete the LMK from the HSM’s database (the lmks table), restart it to create a new LMK, and add the keys again. Keys your systems hold under the old LMK stop working.
  • The vault’s: the stored private keys can’t be opened. Delete the vault’s items, restart it to create a new CA, and issue new certificates. Systems that trust the old CA need the new one.
Setting What it does
HSM_HEADER_LENGTH The length of the header host commands carry and the answer repeats: 4 unless your host applications send another.
HSM_KEY_TYPE_TABLE classic or pci: which key type codes are in force, as on a payShield.
HSM_MAX_CONNECTIONS Connections it keeps at once (200); more are closed as they arrive, and the HSM page counts them.
HSM_TLS_CERTIFICATE A server certificate from the console’s Certificates page, by its id: the HSM then serves TLS on its command port.
HSM_TLS_CLIENT_AUTH none, optional or required: whether connecting systems present a client certificate issued by the install’s CA.

A new install starts with the published Thales test LMK, so keys your systems already hold under it work as they are. An admin can replace it on the HSM page.