OSH

AWS CloudHSM setup

Keep the OSH - CA key in AWS CloudHSM: install the client SDK on the CA machine, create a crypto user and a P-256 key pair, check its fingerprint in OSH - CA, unlock it with the HSM PIN and trust it on your servers.

Before you start

1. Before you start

Choose CloudHSM over AWS KMS only when you must have a single-tenant HSM. A cluster costs about US$1.5 to 3 per HSM per hour (two HSMs for high availability is roughly US$2,300 a month). If Settings → CA Key has no PKCS#11 / AWS CloudHSM Key Source, update OSH - CA first.

The CA key is a P-256 key pair inside your CloudHSM cluster and never leaves it. OSH - CA talks to the HSM through its PKCS#11 library, so the same steps work for other PKCS#11 tokens. The CloudHSM client runs on Linux and Windows only (there is no macOS client), and the CA machine must reach the cluster's network: the same VPC, peering, a VPN or Direct Connect. The CloudHSM audit log does not record each signature; OSH - CA keeps its own record of every certificate it signs.

OSH - CA Settings, CA Key: the Key Source menu open, each source with its own icon: YubiKey (PIV) under Hardware; AWS KMS and PKCS#11 / AWS CloudHSM, both tagged Cloud HSM, under Cloud; and File tagged Software under Software.

Install the CloudHSM client on the CA machine

2. Install the CloudHSM client on the CA machine

Install CloudHSM CLI and the PKCS#11 library of client SDK 5, then point both at the cluster. You need the IP address of one HSM and the customerCA.crt you used to initialize the cluster. For Ubuntu 22.04:

wget https://s3.amazonaws.com/cloudhsmv2-software/CloudHsmClient/Jammy/cloudhsm-cli_latest_u22.04_amd64.deb https://s3.amazonaws.com/cloudhsmv2-software/CloudHsmClient/Jammy/cloudhsm-pkcs11_latest_u22.04_amd64.deb && sudo apt install ./cloudhsm-cli_latest_u22.04_amd64.deb ./cloudhsm-pkcs11_latest_u22.04_amd64.deb

Other Linux versions and Windows: take the matching packages from the AWS CloudHSM documentation.

sudo cp customerCA.crt /opt/cloudhsm/etc/ && sudo /opt/cloudhsm/bin/configure-cli -a <HSM IP> && sudo /opt/cloudhsm/bin/configure-pkcs11 -a <HSM IP>

The library OSH - CA loads is /opt/cloudhsm/lib/libcloudhsm_pkcs11.so on Linux and C:\Program Files\Amazon\CloudHSM\lib\cloudhsm_pkcs11.dll on Windows.

A cluster with a single HSM refuses to create or use keys until both configure tools run once more with --disable-key-availability-check. Keep that for testing; run two HSMs in production.

Create a crypto user and the key pair

3. Create a crypto user and the key pair

Give the CA its own crypto user (CU), then create a P-256 key pair owned by that user, with the same label on both halves. Start CloudHSM CLI, log in as the admin, create the user, then log in as that user and create the key.

/opt/cloudhsm/bin/cloudhsm-cli interactive
login --username admin --role admin
user create --username osh_ca --role crypto-user

A user name may contain only letters, digits and _ (osh-ca is refused). Choose a strong password: it is half of the PIN OSH - CA asks for.

logout
login --username osh_ca --role crypto-user
key generate-asymmetric-pair ec --curve secp256r1 --public-label osh-ca --private-label osh-ca --private-attributes sign=true

Keep the public half: OSH - CA reads the CA public key from it. Keys made this way have no CKA_ID; OSH - CA pairs the two halves by their label.

Work out the fingerprint yourself

4. Work out the fingerprint yourself

Still logged in as the crypto user, export the public key, then let ssh-keygen print its fingerprint. You compare it with the one OSH - CA shows in the next step.

key generate-file --encoding pem --path osh-ca.pem --filter attr.label=osh-ca attr.class=public-key
ssh-keygen -i -m PKCS8 -f osh-ca.pem > k.pub && ssh-keygen -lf k.pub

Run this in a normal terminal, after quitting CloudHSM CLI. It prints SHA256:<base64>.

Check the key, then use it

5. Check the key, then use it

Open OSH - CA, go to Settings → CA Key and choose PKCS#11 / AWS CloudHSM as Key Source. Enter the PKCS#11 library path, the key label (osh-ca) and the HSM PIN, which for CloudHSM is the crypto user and its password joined by a colon: osh_ca:<password>. Leave the token label empty unless the library shows more than one token. Press Check key: OSH - CA logs in, signs a test digest, checks it against the public half and shows the fingerprint. If it matches the one you worked out, press Use this key and confirm. OSH - CA reads the key again, saves it only if the HSM still answers the fingerprint you confirmed, and restarts with it.

The PIN is used for the check only and is never written to disk.

Check key while this CA is already signing with the HSM is refused with lock the CA first: the HSM login is shared, so the new PIN could not be checked. Press Lock, then check.

OSH - CA Settings, CA Key: Key Source set to PKCS#11 / AWS CloudHSM (chip icon), with the PKCS#11 library /opt/cloudhsm/lib/libcloudhsm_pkcs11.so, an empty Token label, the Key label osh-ca, an empty HSM PIN field and a Check key button.

Unlock the CA after every start

6. Unlock the CA after every start

OSH - CA starts locked after every start: it connects to the gateway but refuses to sign until someone types the HSM PIN in Settings and presses Unlock, as with a YubiKey. The PIN stays in memory only.

A Linux CA that runs without a screen reads the PIN from the variable CA_PKCS11_PIN in its service environment instead, and starts unlocked.

CloudHSM locks a crypto user out after a few wrong logins. If the HSM refuses the PIN the CA holds, the CA forgets it and goes locked rather than try again.

Trust the CA on your servers

7. Trust the CA on your servers step by step

In OSH - CA press Copy public key line. It copies ecdsa-sha2-nistp256 followed by the key; pass only the key (the long text after the space) to the install script, as described in Trust the CA. The k.pub file from Work out the fingerprint yourself holds the same line. Do this again whenever you change the HSM key.

What to expect when something goes wrong

8. What to expect when something goes wrong

A locked CA, or one whose HSM refuses the request (session lost, user not logged in, key not found), answers that it cannot sign, and the gateway (0.34.0 or later) retries on another CA. Run a second CA (a different CA ID) for failover.

A signature that does not come back within 12 seconds is not retried elsewhere, because the HSM may already have signed. Measured on a real cluster with the network to the HSM cut: the request waited about 16 seconds, the CA turned not ready, and it signed again about 10 seconds after the network came back, without anyone typing the PIN again.

A key label that holds a key other than the one you confirmed switches the CA off until it restarts.

Troubleshooting

9. Troubleshooting

The HSM refused the PIN (CKR_PIN_INCORRECT): check the user name and the password, joined by a colon. Do not retry many times: the crypto user gets locked out.

Key must be available on at least 2 HSMs: the cluster has one HSM. Add a second HSM, or for testing run configure-cli and configure-pkcs11 with --disable-key-availability-check.

The PKCS#11 library reports no token: the CA machine cannot reach the HSM. Check the security groups, the route to the cluster, and that configure-pkcs11 points at a live HSM IP.

Expected one private key labelled osh-ca, found 0 or 2: the label is wrong, or two key pairs share it. Give each key pair its own label.

© 2026 Open layer technologies L.L.C S.O.C · v0.1.0
Need help? ad@openlay.com