Updated Date: 07/07/2026
Managing External HSM Keys for LTM
You can use the nShield to store and manage token-, module-, and softcard-protected keys.
For additional information about using nShield, refer to the nShield website: (https://www.entrust.com/digital-security/hsm).
There are three types of key protection available for use with the BIG-IP system and nShield:
- Module-protected keys are directly protected by the external HSM through the security world and can be used at any time without further authorization.
- Softcard-protected keys are protected by a softcard and can be used by only an operator who possesses the assigned passphrases.
- Token-protected keys are protected by a cardset and can be used by only an operator who possesses the Operator Card Set (OCS) token and any assigned passphrases.
All options are equally secure, and the main difference is the authorization requirement. As a general rule, if you have no particular security or regulatory requirement, you can default to module protection. nShield prefers the use of physical tokens for authorization. In the case of Operator Cards, nShield recommends making a 1/N card set, where N is greater than the total number of nShields. For more information about card sets, refer to the nShield user guides.
On the BIG-IP system, you can choose among the nShield-supported types of key protection: module, softcard, and OCS. By default, the installation script sets up the appliance to create and use module-protected keys. F5 recommends that you keep only one set of cardset files (cards* or softcard*) in the $NFAST_KMDATA/local directory.
In this release, only one type of key protection (PKCS#11 slot) can be configured for active use. You need to configure the key protection type for a slot by enabling the type you want, and disabling the others.
-
Log in to the command-line interface of the BIG-IP system using an account with administrator privileges.
-
Complete one of these steps, depending on your preferred key protection option:
|
module |
The module-protected key option is enabled by default. To enable this protection type, no further action is required, and you can proceed to the next section. |
|
OCS |
|
|
softcard |
Note: If OCS is configured with a passphrase for nShield HSM, the user must enter it when prompted for Note: To revert back to module protection, change |
-
After you make any configuration changes, you must restart the
pkcs11andtmmservices.tmsh restart sys service pkcs11d tmsh restart sys service tmm
You can use the Traffic Management Shell (tmsh) to generate a key and certificate.
-
Log in to the command-line interface of the system using an account with administrator privileges.
-
Open the TMOS Shell (
tmsh).tmsh -
Generate the key.
create sys crypto key *<key\_name>* gen-certificate common-name *<cert\_name>* security-type nethsmThis example generates an external HSM key named
test_keyand a certificate namedtest_nshield.comwith the security type ofnethsm:create sys crypto key test_key gen-certificate common-name test_nshield.com security-type nethsm -
Verify that the key was created.
list sys crypto key test_key.keyInformation about the key displays:
`sys crypto key test_key.key { key-id <*32-digit string*> key-size 2048 key-type rsa-private security-type nethsm }`
When you generate a key/certificate using tmsh, the system creates a HSM private key. It also creates a local key, which points to the HSM key, residing in the HSM.
If you are configuring the BIG-IP system to manage client-side HTTP traffic, you perform this task to create a self-signed certificate to authenticate and secure the client-side HTTP traffic. If you are also configuring the system to manage server-side HTTP traffic, you must repeat this task to create a second self-signed certificate to authenticate and secure the server-side HTTP traffic.
-
On the Main tab, click System > Certificate Management > Traffic Certificate Management.
The Traffic Certificate Management screen opens.
-
Click Create.
-
In the Name field, type a unique name for the SSL certificate.
-
From the Issuer list, select Self.
-
In the Common Name field, type a name.
This is typically the name of a web site, such as
www.siterequest.com. -
In the Division field, type your department name.
-
In the Organization field, type your company name.
-
In the Locality field, type your city name.
-
In the or State or Province field, type your state or province name.
-
From the Country list, select the name of your country.
-
In the E-mail Address field, type your email address.
-
In the Lifetime field, type a number of days, or retain the default, 365.
-
In the Subject Alternative Name field, type a name.
This name is embedded in the certificate for X509 extension purposes.
By assigning this name, you can protect multiple host names with a single SSL certificate.
-
From the Security Type list, select NetHSM.
-
From the Key Type list, RSA is selected as the default key type.
-
From the Size list, select a size, in bits.
-
Click Finished.
You perform this task to generate a certificate signing request (CSR) that can then be submitted to a third-party trusted certificate authority (CA).
Note: F5 Networks recommends that you consult the CA to determine the specific information required for each step in this task.
-
On the Main tab, click System > Certificate Management > Traffic Certificate Management.
The Traffic Certificate Management screen opens.
-
Click Create.
-
In the Name field, type a unique name for the SSL certificate.
-
From the Issuer list, select Certificate Authority.
-
In the Common Name field, type a name.
This is typically the name of a web site, such as
www.siterequest.com. -
In the Division field, type your department name.
-
In the Organization field, type your company name.
-
In the Locality field, type your city name.
-
In the or State or Province field, type your state or province name.
-
From the Country list, select the name of your country.
-
In the E-mail Address field, type your email address.
-
In the Lifetime field, type a number of days, or retain the default, 365.
-
In the Subject Alternative Name field, type a name.
This name is embedded in the certificate for X509 extension purposes.
By assigning this name, you can protect multiple host names with a single SSL certificate.
-
In the Challenge Password field, type a password.
-
In the Confirm Password field, re-type the password you typed in the Challenge Password field.
-
From the Security Type list, select NetHSM.
-
From the Key Type list, RSA is selected as the default key type.
-
From the Size list, select a size, in bits.
-
Click Finished.
The Certificate Signing Request screen displays.
-
Do one of the following to download the request into a file on your system.
- In the Request Text field, copy the certificate.
- For Request File, click the button.
-
Follow the instructions on the relevant certificate authority web site for either pasting the copied request or attaching the generated request file.
-
Click Finished.
The Certificate Signing Request screen displays.
The generated certificate signing request is submitted to a trusted certificate authority for signature.
You perform this task to delete an existing key from the BIG-IP.
-
On the Main tab, click System > Certificate Management > Traffic Certificate Management.
The Traffic Certificate Management screen opens.
-
From the SSL Certificate List, select the check box next to the key you wish to delete.
-
Click Delete.
The key you selected is deleted from BIG-IP.
Note: The key stored in NetHSM is not deleted.
After you have added the external HSM key and certificate to the BIG-IP system configuration, you can use the key and certificate as part of a client SSL profile. This task describes using the browser interface. Alternatively, you can use the Traffic Management Shell (tmsh) command-line utility.
-
On the Main tab, click Local Traffic > Profiles > SSL > Client.
The Client screen opens.
-
Click Create.
The New Client SSL Profile screen opens.
-
In the Name field, type a name for the profile.
-
From the Parent Profile list, select clientssl.
-
From the Configuration list, select Advanced.
This selection makes it possible for you to modify additional default settings.
-
For the Configuration area, select the Custom check box.
The settings in the Configuration area become available for modification.
-
Using the Certificate Key Chain setting, specify one or more certificate key chains:
-
From the Certificate list, select the name of a certificate that you imported.
-
From the Key list, select the name of the key that you imported.
-
From the Chain list, select the chain that you want to include in the certificate key chain.
-
Click Add.
-
-
Click Finished.
After you have created the client SSL profile, you must assign the profile to a virtual server, so that the virtual server can process SSL traffic according to the specified profile settings.
Before you begin this task, make sure that the nShield client is installed and configured on the BIG-IP system.
If you already have regular RSA keys, you can migrate them to the nShield HSM.
Note: A nShield HSM device that is configured with the Strict FIPS 140-2 Level 3 compliance flag prevents importation of extraneous private keys.
-
Log in to the command-line interface of the system using an account with administrator privileges.
-
Migrate the key.
fipskey.nethsm --export -i <*input\_key\_full\_path\_filename*> -o output_key_filenameThis example generates the four files that follow:
fipskey.nethsm --export -i regular_key -o hsm_key/config/ssl/ssl.key/hsm_key.key(local key)/config/ssl/ssl.csr/hsm_key.csr(CSR file)/config/ssl/ssl.crt/hsm_key.crt(self-signed certificate)/opt/nfast/kmdata/local/*protected\_key\_filename*(protected key)
If you migrated a key that has a certificate that is already issued by a reputable issuing CA, you should migrate the key, but continue using the old certificate. After you migrate the existing key to the nShield HSM, you must load the key into the BIG-IP system using tmsh, and then modify the client SSL profile, or create a new client SSL profile that uses the new key and the existing certificate.
You import existing SSL keys when you have pre-existing keys you want the BIG-IP system to use. You need to perform these steps for each key you want to import into the nShield system.
-
Log in to the command-line interface of the system using an account with administrator privileges.
-
Copy certificate(s) and key(s) you want to import onto the BIG-IP system and place them in the
/var/tmpdirectory on the BIG-IP system.`/var/tmp/user.key` `/var/tmp/user.crt` -
Ensure adequate permissions are set so that other users on the system are not able to view the
.keyfiles copied.chmod 600 /var/tmp/user.key -
Import the key into nShield external HSM using the generatekey utility.
/opt/nfast/bin/generatekey --import pkcs11 certreq=yesThe system interactively prompts you for information.
-
When prompted to enter the name of the PEM file that contains the RSA key, enter the full path to the key copied to the BIG-IP system (pemreadfile).
For example,
/var/tmp/user.key. -
When prompted to enter the file name where the key will be written, enter the full path to the pseudo key (embedsavefile).
This is the pseudo key required by BIG-IP system.
For example,
/var/tmp/imported_user.key. -
When prompted to enter the key name, type a name for the key (plainname).
This is the name with which the key is associated in the nShield RFS. No path is required, as plainname is not written to a file on disk.
For example,
userkey.When the key import is complete, the
generatekeyutility will generate two files.imported_user.keyimported_user_req
-
Modify the ownership and permissions of the key you created. After successful import, take note of the path to key to modify ownership.
`chown nfast:nfast /opt/nfast/kmdata/local/key_pkcs11_uced028e5251b7b6891e7e59dec5428d871f92241b-c70e6451e8d793ca80a497267ccb9bc73bd55edb` `chmod 755 /opt/nfast/kmdata/local/key_pkcs11_uced028e5251b7b6891e7e59dec5428d871f92241b-c70e6451e8d793ca80a497267ccb9bc73bd55edb`Important: If this step is omitted, you might see permission errors when running
rfs-sync. -
Sync the nShield generated pseudo-key (embedsavefile) to the RFS.
`[root@hostname:Active:Standalone] tmp # rfs-sync --update` `[root@hostname:Active:Standalone] tmp # rfs-sync --commit`If the BIG-IP system this procedure is performed on is also the RFS, the
rfs-synccommands above will report0 committed. This is expected behavior, as the keys imported are automatically stored in the RFS directory. -
Import the pseudo key and SSL certificate using
tmshfor use by BIG-IP client SSL profile using this syntax:tmsh install sys crypto key \[name\] from-local-file \[/path/to/pseudo\_key.key\] tmsh install sys crypto cert \[name\] from-local-file \[/path/to/real\_certificate.crt\]For example:
`tmsh install sys crypto key import.key from-local-file /var/tmp/imported_user.key` `tmsh install sys crypto cert import.crt from-local-file /var/tmp/user.crt` -
Save the configuration.
tmsh save sys configIf you need to import more SSL certificates and keys, repeat all preceding steps for each certificate and key pair.
-
Create an SSL profile that references the above key and certificate.
-
Create a virtual server that uses the above SSL profile (or assign to an existing virtual server).
-
Verify that the virtual server passes traffic correctly.
-
You can safely remove the certificates and keys from
/var/tmpdirectory used in this procedure as they are no longer required by the BIG-IP system.Note: Once the pseudo key has been installed with
tmsh, the copy in/var/tmpis no longer used.Note: Unless the SSL key file is deleted in a secure manner, it might be possible for someone to recover the file from the disk. Consider using the
shredutility (typeman shredat the command line for details) to delete any key files copied to the BIG-IP system once they have been successfully imported into the nShield device.Note: When you create a new nShield key for BIG-IP HA, you must run the command
rfs-sync --updateon all standby BIG-IP devices to update the local nShield encrypted file object cache. Without this action, SSL traffic using this key will fail when BIG-IP fails over to one of the unsynced standby devices.
-
On the Main tab, click System > Certificate Management > Traffic Certificate Managment > SSL Certificate List > Import.
The SSL Certificate/Key Source page opens.
-
Within Import Type, select Key.
The key name should be the same as the NetHSM key label.
-
Within Key Name, select Overwrite Existing and from the drop-down menu, select the key you would like to overwrite.
-
Within Key Source, select From NetHSM.
For this option to be available, the system must have External HSM licensed, and either SafeNet/nShield External HSM configured.
-
Click Import.
You can also import an existing key by using tmsh commands tmsh install sys crypto key nethsm_key_label from-nethsm security-type or tmsh install sys crypto key nethsm_key_label from-nethsm. Use the NetHSM key label as the key name. For example:
root@(hostname)(Standalone)(Active)(/Common)(tmos)# install sys crypto key nethsm_key_label (tab)
Options:
from-editor from-nethsm
Properties:
from-local-file from-url
root@(hostname)(Standalone)(Active)(/Common)(tmos)# install sys crypto key nethsm_key_label from-nethsm security-type nethsm