Troubleshooting PKCS#11 for OpenSSL
-
Follow the Primus PKCS#11 Provider troubleshooting to verify that it is installed correctly. Use
ppin --testto check that all HSMs can be reached. If this fails, the provider will also not show in OpenSSL. -
To verify that the provider is loaded correctly, list the active providers:
openssl list -providersIf the OpenSSL PKCS#11 provider has been configured successfully,
pkcs11should appear in the list. If there is any error in the entire chain from OpenSSL via the PKCS#11 Provider to the HSM,pkcs11will not appear in this list. This is why it is important to do the PKCS#11 Provider troubleshooting first. -
List the available signature algorithms. It should display algorithms with
@pkcs11appended.openssl list -signature-algorithms{ 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ default{ 1.2.840.10040.4.1, 1.2.840.10040.4.3, 1.3.14.3.2.12, 1.3.14.3.2.13, 1.3.14.3.2.27, DSA, DSA-old, DSA-SHA, DSA-SHA1, DSA-SHA1-old, dsaEncryption, dsaEncryption-old, dsaWithSHA, dsaWithSHA1, dsaWithSHA1-old } @ default{ 1.3.101.112, ED25519 } @ default{ 1.3.101.113, ED448 } @ default{ 1.2.156.10197.1.301, SM2 } @ defaultECDSA @ defaultHMAC @ defaultSIPHASH @ defaultPOLY1305 @ defaultCMAC @ default{ 1.2.840.113549.1.1.1, 2.5.8.1.1, RSA, rsaEncryption } @ pkcs11{ 1.3.101.112, ED25519 } @ pkcs11{ 1.3.101.113, ED448 } @ pkcs11ECDSA @ pkcs11 -
The pkcs11-provider implements lazy module loading by default. We recommend to change the loading behavior by setting
pkcs11-module-load-behavior = earlyin the[pkcs11_sect]of your OpenSSL configuration file. See the configuration guide.The
earlyload is needed when working with OpenSSL on the command line. For example, the supported signature algorithms don't show up with lazy loading. -
Check the pkcs11-provider logs. The logs can be controlled with the
PKCS11_PROVIDER_DEBUGenvironment variable. For instancePKCS11_PROVIDER_DEBUG=file:/tmp/p11prov-debug.log,level=5will send the logs to /tmp/p11prov-debug.log. The logs will tell you ifpkcs11-module-pathpoints to a valid provider library and if the interaction with it is successful. Below, the (abbreviated) content of p11prov-debug.log provider logs just after starting openssl is shown. The lines to look out for when analyzing the logs are highlighted. The table contains a brief description of the action that is related to the log entry. Don't forget to disable the logging after troubleshooting.Line-# Corresponding action 1-2 Dump of the configuration the pkcs11-provider received. 4 Initializing of the Securosys PKCS#11 provider library. 9 The Securosys PKCS#11 provider was successfully loaded. 18-30 Dump of the slot/token information received from the HSM. [../../../../src/provider.c:1347] OSSL_provider_init(): Provided config params:[../../../../src/provider.c:1357] OSSL_provider_init(): pkcs11-module-path: /usr/local/primus/lib/libprimusP11.so...[../../../../src/interface.c:291] p11prov_module_init(): PKCS#11: Initializing the module: /usr/local/primus/lib/libprimusP11.so[../../../../src/interface.c:175] p11prov_interface_init(): C_GetInterface() not available. Falling back to C_GetFunctionList(): usr/local/primus/lib/libprimusP11.so: undefined symbol: C_GetInterface[../../../../src/interface.c:102] populate_interface(): Populating Interfaces with 'Internal defaults', version 2.20[../../../../src/interface.gen.c:13] p11prov_Initialize(): Calling C_Initialize[../../../../src/interface.gen.c:51] p11prov_GetInfo(): Calling C_GetInfo[../../../../src/interface.c:327] p11prov_module_init(): Module Info: ck_ver:3.0 lib: 'Securosys SA' 'PKCS#11 Library' ver:2.1...[../../../../src/interface.gen.c:468] p11prov_FindObjects(): Calling C_FindObjects[../../../../src/interface.gen.c:488] p11prov_FindObjectsFinal(): Calling C_FindObjectsFinal[../../../../src/slot.c:68] get_slot_profiles(): No profiles for slot 1[../../../../src/interface.gen.c:234] p11prov_CloseSession(): Calling C_CloseSession[../../../../src/interface.gen.c:173] p11prov_GetMechanismList(): Calling C_GetMechanismList[../../../../src/slot.c:100] get_slot_mechanisms(): Slot(1) mechs found: 105[../../../../src/interface.gen.c:173] p11prov_GetMechanismList(): Calling C_GetMechanismListSlot Info:ID: 1Description: [OPENSSL_PKCS11_INT_TEST]Manufacturer ID: [Securosys SA]Flags (0x000005):CKF_TOKEN_PRESENT (0x000001)CKF_HW_SLOT (0x000004)Hardware Version: 2.11Firmware Version: 2.1Token Info:Label: [OPENSSL_PKCS11_INT_TEST]Manufacturer ID: [Securosys SA]Model: [Primus HSM]... -
OpenSSL loads its providers sequentially. If any of the OpenSSL provider crashes, all providers are not loaded. In particular, in combination with
pkcs11-module-load-behavior = early, this means that if the Primus PKCS#11 Provider fails to connect to any of the configured HSMs (e.g., due to a network issue), the entire OpenSSL functionality may stop working. If configured globally, this can impact other applications, such assshd.We recommend to create an application-specific OpenSSL config file, instead of adding the PKCS#11 integration to the global config.
-
Primus PKCS#11 Provider < v2.5.x is not compatible with OpenSSL's pkcs11-provider.