Auto Light Dark
Auto Light Dark

Integration Steps on Keyfactor EJBCA

  • 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.properties and restarting WildFly, the Crypto Token can be created from the Administration Web Interface.


image-20261122-034226.png


image-20261122-034042.png


PKCS11 Type and supported library list

Configuration 

  1. Access the EJBCA CLI through an SSH session.

  2. Copy the HSM configuration file, cs_pkcs11_R3.cfg, and the Utimaco PKCS#11 library libcs_pkcs11_R3.so to the /etc/utimaco/ directory.

  3. Update cs_pkcs11_R3.cfg according to the HSM IP address in the configuration file and save the changes.

Configure web.properties for Utimaco HSM

  1. Update the HSM-specific configuration in $EJBCA_HOME/conf/web.properties to 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


image-20261122-213757.png


HSM-specific configuration

  1. Open the EJBCA Admin web UI and Utimaco PKCS11 library displayed in PKCS#11 : Library dropdown.

image-20261122-224800.png


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.

  1. Set the CS_PKCS11_R3_CFG environment variable in the /etc/wildfly/wildfly.conf configuration file.

# The location for the Utimaco PKCS#11 R3 configuration
CS_PKCS11_R3_CFG=/etc/utimaco/cs_pkcs11_R3.cfg
image-20261122-232227.png


Configuration file

  1. After updating the configuration, restart the WildFly service 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.

  1. Copy libcs_pkcs11_R3.so to the /root/utimaco/ directory.

  2. Use the ejbcaClientToolBox.sh script to generate keys in the HSM.

  3. Key generation command:

$EJBCA_HOME/dist/clientToolBox/ejbcaClientToolBox.sh PKCS11HSMKeyTool generate /<folder path>/libcs2_pkcs11.so <Key_size> <Key_Alias> <Slot_ID>
image-20261123-002539.png


Keys created

  1. 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      |


  1. 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.sh script 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
image-20261123-004937.png


Signing performance test file

 

Create a Crypto Token from the Administration Web Interface

  1. 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.

image-20261123-050037.png


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.

 

image-20261123-044746.png

Crypto token Utimaco-HSM-Test created

  1. 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.


image-20261123-061307.png


Key creation

2.3. The newly created key is displayed on the Crypto Token page under the Manage key pair section.

image-20261123-061541.png


Created key updated in EJBCA

2.4. Check that the newly created key has been updated in HSM.


./p11tool2 slot=0 LoginUser=<pin> ListObjects
image-20261123-061900.png

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.


image-20261123-044235.png


Manage key pairs section with key details

4. The confirmation message is displayed for each key.

image-20261123-024547.png
image-20261123-030559.png
image-20261123-030640.png




Signing completed with all 3 keys