Start with pkcs11-manager and logging
Reproduce the problem with the packagedpkcs11-manager utility before you debug it inside your application. The utility isolates whether the module loads, reads its configuration, reaches CryptoHub, and authenticates:
pkcs11-manager
logging block of cryptohub.json, set mode to DEBUG and enable trace_logging. Send output to the console or a file so you can read it:
Configuration file not found or not parsed
If the module behaves as though it has no configuration, confirm it is reading the file you expect.- Wrong file loaded. The module uses the first file it finds in the discovery order:
CHLIBS_CONFIG, thencryptohub.jsonin the current working directory, then../config/cryptohub.json, then the platform static paths. A straycryptohub.jsonin the working directory overrides the system-wide file. SetCHLIBS_CONFIGto an absolute path to remove ambiguity. - Service account or custom working directory. When your application runs under a service account, its working directory may not be what you expect. Set
CHLIBS_CONFIGrather than relying on a relative path. - JSON parse errors. A malformed file prevents the module from initializing. Validate the file as JSON, and check that variable substitutions (
${env:...},${conf},${reg:...}) resolve — an unset environment variable can leave a field empty.
CryptoHub REST unreachable
If initialization fails at the connection stage, verify network reachability to each destination’sbase_uri.
- Confirm the host can reach every
cryptohubs[].base_uriover HTTPS, and that firewalls and any HTTPproxysetting permit the connection. - Check that the URI scheme, host, and port are correct and that the CryptoHub REST service is running.
- If some destinations are unreachable, remember that
PRODUCTIONentries load-balance andBACKUPentries are tried only after all production entries fail. A destination withroleset toNONEis never used.
TLS chain or hostname validation failures
TLS problems surface as handshake or verification errors during initialization.- When
tls.verifyistrue, the server certificate chain must validate against the CA files listed intls.authorities. Confirm those files exist and contain the correct issuing CAs. - When
tls.verify_hostnameistrue, the certificate must match the hostname inbase_uri. A certificate issued to an IP address or a different name fails this check. - If you restrict
tls.protocol_minandtls.protocol_maxor thetls.cipherslist, make sure CryptoHub supports the negotiated protocol and cipher. - For mutual TLS, confirm the
tls.client_file(or Windowstls.windows) certificate and its password are correct.
Authentication failures
Authentication applies globally to all CryptoHub destinations and is configured in theauthentication block. It is optional when you authenticate with client (mutual) TLS.
- Credentials. Confirm exactly one authentication method is configured and correct:
users(username/password),api_key, or PKI (pki_key/pki_authwithpki_cert). Secrets supplied through${env:...}fail silently if the environment variable is unset. - PKI nonce-signature. For PKI authentication, confirm the client PKI certificate and password are correct and that CryptoHub trusts the certificate.
- Backend cluster authentication. If your deployment uses a backend balancing cluster, the
cluster_authenticationblock governs cluster login. For an anchor HSM cluster the module uses your authentication credentials by default; for a non-anchor cluster it uses the system users by default. Configurecluster_authenticationexplicitly if the defaults do not apply.
Service or key-store lookup problems
If the module authenticates but exposes no keys, or the wrong keys, check theglobal service and key-store settings.
- Confirm
service_uuididentifies the intended CryptoHub service andkey_store_namenames a key store within it. Only keys in that key store are used. - Confirm the key store’s protection model matches
key_protection. The module uses the key store whose protection model and service match. - If keys you just created do not appear, set
reload_on_cache_misstotrueso the module reloads the cache after a lookup miss, or reinitialize the module. - If a certificate does not match its private key, review
cert_id_mode.DefaultderivesCKA_IDfrom CryptoHub checksums so matching keys and certificates share an ID;MetadataandKeyUuidderive it differently. See Architecture.
Protection-model mismatch
An operation can fail because the key’s protection model does not permit it. For example, wrapping techniques that do not require an HSM login are available underPROTECTED but not under TRUSTED or STORED. Confirm that key_protection matches both the key store you target and the operations you intend to perform.
Operation rejected even though the mechanism is advertised
A mechanism appearing inC_GetMechanismList does not guarantee an operation succeeds.
- CryptoHub policy and key metadata. CryptoHub enforces per-key usage and service policy. An operation the mechanism supports can still be rejected by policy. Confirm the key’s CryptoHub usage permits the operation.
- Module usage configuration. The
pkcs11.forced_usages,pkcs11.forced_usages.by_label, andpkcs11.default_usagessettings can constrain usage for AES, DES, RSA, and ECC keys.forced_usagesoverrides everything, so a forced usage that omits your operation blocks it regardless of the template. See Configuration.
PKCS#11 v3.2 consumer compatibility
Some consumers do not understand the PKCS#11 v3.2 interface this module implements.- A consumer built against an older Cryptoki header may not recognize the v3.2 KEM functions (
C_EncapsulateKey,C_DecapsulateKey) or the post-quantum mechanisms and attributes. - Java’s SunPKCS11 provider and the JDK may lag the module’s v3.2 post-quantum and KEM features. The native provider can expose mechanisms the SunPKCS11 layer cannot name or invoke. For post-quantum operations, prefer the native C interface, or confirm your JDK and SunPKCS11 build support the mechanisms. See Post-quantum cryptography.
Post-quantum parameter-set or template mismatch
When post-quantum operations fail, check the return value:Where to look next
- Confirm the field values you are debugging against the Configuration reference.
- Confirm which operations are local and which require CryptoHub in Architecture.
- Confirm the mechanisms and parameter sets your build advertises in Appendix A.

