-
To create a Crypto Token through the Admin Web UI, navigate to CA Functions → Crypto Tokens. By default, the Utimaco PKCS#11 library is not available in the EJBCA Web UI. After registering the library in
web.propertiesand restartingWildFly, the Crypto Token can be created from the Administration Web Interface.
PKCS11 Type and supported library list
Configuration
-
Access the EJBCA CLI through an SSH session.
-
Copy the HSM configuration file,
cs_pkcs11_R3.cfg, and the Utimaco PKCS#11 librarylibcs_pkcs11_R3.soto the/etc/utimaco/directory. -
Update
cs_pkcs11_R3.cfgaccording to the HSM IP address in the configuration file and save the changes.
Configure web.properties for Utimaco HSM
-
Update the HSM-specific configuration in
$EJBCA_HOME/conf/web.propertiesto register the Utimaco R3 PKCS#11 library.
#Utimaco SecurityServer 6.6 PKCS#11 R3
cryptotoken.p11.lib.36.name=Utimaco R3
cryptotoken.p11.lib.36.file=/etc/utimaco/libcs_pkcs11_R3.so
HSM-specific configuration
-
Open the EJBCA Admin web UI and Utimaco PKCS11 library displayed in PKCS#11 : Library dropdown.
PKCS11 library displayed in Web UI
Wildfly Environment Update
EJBCA runs within the WildFly application server. Therefore, the PKCS#11 configuration environment variable must be added to the WildFly service environment.
-
Set the
CS_PKCS11_R3_CFGenvironment variable in the/etc/wildfly/wildfly.confconfiguration file.
# The location for the Utimaco PKCS#11 R3 configuration
CS_PKCS11_R3_CFG=/etc/utimaco/cs_pkcs11_R3.cfg
Configuration file
-
After updating the configuration, restart the
WildFlyservice to apply the changes.
sudo systemctl status wildfly
Generate HSM Keys
Keys can be generated using either the EJBCA CLI or the Administration Web interface. This section describes the key generation procedure using the EJBCA CLI.
-
Copy
libcs_pkcs11_R3.soto the/root/utimaco/directory. -
Use the
ejbcaClientToolBox.shscript to generate keys in the HSM. -
Key generation command:
$EJBCA_HOME/dist/clientToolBox/ejbcaClientToolBox.sh PKCS11HSMKeyTool generate /<folder path>/libcs2_pkcs11.so <Key_size> <Key_Alias> <Slot_ID>
Keys created
-
The following keys are generated in the HSM:
-
-
signKey -
defaultKey -
testKey
-
[root@ip-172-31-88-33 Administration]# ./p11tool2 LoginUser=12345678 ListObjects
CKO_CERTIFICATE:
+ 1.1
CKA_CERTIFICATE_TYPE = CKC_X_509
CKA_UNIQUE_ID = 481CC0A7-11A6-4B1F-93A2-7409CE99ACB7
CKA_LABEL = testKey
CKA_ID = 0x74657374 4B6579 (testKey)
CKA_SUBJECT =
0x30463144 30420603 5504030C 3B44756D |0F1D0B U ;Dum|
6D792063 65727469 66696361 74652063 |my certificate c|
72656174 65642062 79206120 43455365 |reated by a CESe|
436F7265 20617070 6C696361 74696F6E |Core application|
20323432 33313335 | 2423135 |
+ 1.2
CKA_CERTIFICATE_TYPE = CKC_X_509
CKA_UNIQUE_ID = A509EA00-4283-4135-959C-999464C36FC7
CKA_LABEL = defaultKey
CKA_ID =
0x64656661 756C744B 6579 |defaultKey |
CKA_SUBJECT =
0x30463144 30420603 5504030C 3B44756D |0F1D0B U ;Dum|
6D792063 65727469 66696361 74652063 |my certificate c|
72656174 65642062 79206120 43455365 |reated by a CESe|
436F7265 20617070 6C696361 74696F6E |Core application|
20363137 34313435 | 6174145 |
+ 1.3
CKA_CERTIFICATE_TYPE = CKC_X_509
CKA_UNIQUE_ID = 15075D7F-E8EE-4E6D-854F-240BBE6DF992
CKA_LABEL = signKey
CKA_ID = 0x7369676E 4B6579 (signKey)
CKA_SUBJECT =
0x30463144 30420603 5504030C 3B44756D |0F1D0B U ;Dum|
6D792063 65727469 66696361 74652063 |my certificate c|
72656174 65642062 79206120 43455365 |reated by a CESe|
436F7265 20617070 6C696361 74696F6E |Core application|
20313437 32313436 | 1472146 |
CKO_PRIVATE_KEY:
+ 2.1
CKA_KEY_TYPE = CKK_RSA
CKA_UNIQUE_ID = 113BEF6E-BF61-4A68-8D39-52F29BE0F436
CKA_SENSITIVE = CK_TRUE
CKA_EXTRACTABLE = CK_FALSE
CKA_LABEL = priv-signKey
CKA_ID = 0x7369676E 4B6579 (signKey)
+ 2.2
CKA_KEY_TYPE = CKK_RSA
CKA_UNIQUE_ID = 8037C096-5CF1-4DD0-A2FA-2C00762DD884
CKA_SENSITIVE = CK_TRUE
CKA_EXTRACTABLE = CK_FALSE
CKA_LABEL = priv-testKey
CKA_ID = 0x74657374 4B6579 (testKey)
+ 2.3
CKA_KEY_TYPE = CKK_RSA
CKA_UNIQUE_ID = FEBAD5EC-6421-494F-AD50-EE702B5DDC0E
CKA_SENSITIVE = CK_TRUE
CKA_EXTRACTABLE = CK_FALSE
CKA_LABEL = priv-defaultKey
CKA_ID =
0x64656661 756C744B 6579 |defaultKey |
-
Perform a signing operation using the generated HSM keys to verify that the keys are accessible and can be used for cryptographic operations. Use the
p11ng-cli.shscript to perform the signing performance test with the generated keys.
EJBCA_HOME/dist/p11ng-cli/p11ng-cli.sh signperformancetest \
--lib-file /root/utimaco/libcs_pkcs11_R3.so \
--slot 0 \
--alias signKey \
--time-limit 5000 \
--signature-algorithm SHA256withRSA \
--verify
Signing performance test file
Create a Crypto Token from the Administration Web Interface
-
Create a crypto token by selecting the Utimaco R3 library, Slot Index in Reference Type, and the corresponding slot in Reference, then provide the corresponding User PIN in Authentication Code. Click Save.
Crypto token created
For this validation, the crypto token Utimaco-HSM-Test is created, and EJBCA successfully discovered the existing HSM keys signKey (RSA4096), defaultKey (RSA 2048), and testKey (RSA 512). This is possible only if the keys are already available in the selected slot.
Crypto token Utimaco-HSM-Test created
-
Create Keys using the administration web UI if the keys are not present in the selected slot.
2.1. Keys can be generated in the Crypto Token page under the Generate new key pair section.
2.2. Enter the key name and select the algorithm and usage. Click Generate.
Key creation
2.3. The newly created key is displayed on the Crypto Token page under the Manage key pair section.
Created key updated in EJBCA
2.4. Check that the newly created key has been updated in HSM.
./p11tool2 slot=0 LoginUser=<pin> ListObjects
Created key updated in HSM
3. To verify the signing and verification operations of the keys, click the Test button for each key in the Manage key pair section.
Manage key pairs section with key details
4. The confirmation message is displayed for each key.
Signing completed with all 3 keys