Page 1 of 12
Avi Vantage Integration with SafeNet Network HSM (16.2) view online Note: Users of more recent releases of Avi Vantage than 16.2 are invited to instead read Avi Vantage Integration with SafeNet Network HSM (16.2.2), Avi Vantage Integration with SafeNet Network HSM (16.2.3) or Avi Vantage Integration with SafeNet HSM (16.3.2+). Introduction Avi Vantage includes support for networked hardware security module (HSM) products, including SafeNet Network HSM and Thales nshield. This article covers the SafeNet Network HSM (formerly Luna SA) integration. For Thales nshield support, see here. This article describes how to configure Avi Vantage to use the key generation and encryption/decryption services provided by SafeNet Network HSM. This enables use of SafeNet Network HSM to store keys associated with SSL/TLS resources configured on a virtual service. Integration Support Avi Vantage release 16.2 uses SafeNet Network HSM Client Software Release 5.4.1 for 64-bit Linux. Avi Vantage can be configured to support a cluster of HSM devices in high availability (HA) mode. Avi Vantage support of HSM devices requires installation of the user's SafeNet Client Software bundle, which can be downloaded from the SafeNet/Gemalto website. Prerequisites Before using Avi Vantage with SafeNet Network HSM, the following are required: SafeNet devices are installed on your network. SafeNet devices are reachable from the Avi Controller and Avi Service Engines. SafeNet devices have a virtual HSM partition defined before installing the client software. Each Avi Controller and Service Engine must: 1. Have the client license from SafeNet to access the HSM. Download: 2) Be able to reach the HSM at ports 22 and 1792 through Avi Controller, or SE management interface. SafeNet Network HSM client software (Version 5.4) SafeNet Network HSM customer documentation HSM Group Updates Creation, update or deletion of an HSM group requires reloading of a new SafeNet configuration, which can only be achieved by restarting the Avi SEs. Restart of Avi SEs temporarily disrupts traffic. Copyright 2018 Avi Networks, Inc. Page 2 of 12
SafeNet Software Import To enable support for SafeNet Network HSM, the downloaded SafeNet client software bundle must be uploaded to the Avi Controller. It must be named "safenet.tar" and can be prepared as follows: Copy files from the downloaded software into any given directory (e.g., safenet_pkg). Change directory (cd) to that directory, and enter the following cp commands: cd safenet_pkg cp 610-012382-008_revC/linux/64/configurator-5.4.1-2.x86_64.rpm configurator-5.4.1-2.x86_64.rpm cp 610-012382-008_revC/linux/64/libcryptoki-5.4.1-2.x86_64.rpm libcryptoki-5.4.1-2.x86_64.rpm cp 610-012382-008_revC/linux/64/vtl-5.4.1-2.x86_64.rpm vtl-5.4.1-2.x86_64.rpm cp 610-012382-008_revC/linux/64/lunacmu-5.4.1-2.x86_64.rpm lunacmu-5.4.1-2.x86_64.rpm cp 610-012382-008_revC/linux/64/cklog-5.4.1-2.x86_64.rpm cklog-5.4.1-2.x86_64.rpm cp 610-012382-008_revC/linux/64/multitoken-5.4.1-2.x86_64.rpm multitoken-5.4.1-2.x86_64.rpm cp 610-012382-008_revC/linux/64/ckdemo-5.4.1-2.x86_64.rpm ckdemo-5.4.1-2.x86_64.rpm cp 610-012382-008_revC/linux/64/lunacm-5.4.1-2.x86_64.rpm lunacm-5.4.1-2.x86_64.rpm tar -cvf safenet.tar configurator-5.4.1-2.x86_64.rpm libcryptoki-5.4.1-2.x86_64.rpm vtl-5.4.1-2.x86_64.rpm lunacm In Avi Vantage 16.2, HSM package upload is supported only through the CLI. You can use the following command in the Avi Controller CLI shell to upload the HSM package: upload hsmpackage filename /tmp/safenet_pkg/safenet.tar HSM Package uploaded successfully This command uploads the packages and installs them on the Avi Controller or Avi Controllers (if clustered). If the Controller is deployed as a 3-node cluster, the command installs the packages on all 3 nodes. Upon completion, "HSM Package uploaded successfully" should appear as shown above. Avi SEs in an SE group referring to an HSM group need a one-time reboot for auto-installation of the HSM packages. To reboot an Avi SE, issue the following CLI shell command: reboot serviceengine Avi-se-ksueq To allow Avi Controllers to talk to SafeNet HSM, the SafeNet client software bundle distributed with the product must be uploaded to Avi Vantage. The software bundle preparation and upload is described above. In this example, note that the Avi SE name is "Avi-se-ksueq." Enabling HSM Support in Avi Vantage After using the above steps to install the SafeNet software bundle onto the Avi Controller, the Controller may be configured to secure virtual services with HSM certificates. 1. Create the HSM group and add the HSM devices to it. 2. Register the client with HSM devices. 3. Set up HA across HSM devices (optional). Copyright 2018 Avi Networks, Inc. Page 3 of 12
4. Associate the HSM group with the SE group. 5. Add the application certificates and keys by importing them. These are the keys and certificates generated out of band. 6. Enable HSM support on a virtual service. Detailed steps are provided in the following sections. Step 1: Create the HSM Group and Add the HSM Devices to It To begin, use the following commands on controller bash shell to fetch the certificates of the HSM servers. The example below fetches certificates from two servers 1.1.1.11 and 1.1.1.13 sudo scp admin@1.1.1.11:server.pem hsmserver11.pem sudo scp admin@1.1.1.13:server.pem hsmserver13.pem The contents of these certificates are used while creating the HSM Group. Next, create the HSM group. From the GUI, navigate to Templates > Security > HSM Groups. Multiple HSMs may be included in the group via the green Add Additional HSM button. Copyright 2018 Avi Networks, Inc. Page 4 of 12
This can also be configured using the Controller CLI shell: configure hardwaresecuritymodulegroup safenet-network-hsm-1 hardwaresecuritymodulegroup > hsm type hsm_type_safenet_luna hardwaresecuritymodulegroup:hsm >sluna hardwaresecuritymodulegroup:hsm:sluna >server New object being created hardwaresecuritymodulegroup:hsm:sluna:server >remote_ip 1.1.1.11 hardwaresecuritymodulegroup:hsm:sluna:server >server_cert -- Please input the value for field server_cert (Enter END to terminate input): -----BEGIN CERTIFICATE----- MIIDKzCCAhOgAwIBAgIBADANBgkqhkiG9w0BAQsFADBZMQswCQYDVQQGEwJDQTEQ Copyright 2018 Avi Networks, Inc. Page 5 of 12
MA4GA1UECBMRF250YXJpbzEPMA0GA1UEBxMGT3R0YXdhMRYwFAYDVQQKEw1DaHJ5 c2fsaxmtsvrtmq8wdqydvqqdewzlbgfimtewhhcnmtmwnzi1mtqxodqzwhcnmjmw gpqyjsxhgury50vokfrlky9slvbopbhofpzpgjut3pckjdfskljsadlkjdsfkjjj 8M5XErJL0Wek4AkZg7kvM9JuKFJpvdLqkdbJfNFKfjAKEI3fpupmREPXMvAXgeU= NzI3MTQxODQzWjBZMQswCQYDVQQGEwJDQTEQMA4GA1UECBMHT250YXJpbzEPMA0G A1UEBxMGT3R0YXdhMRYwFAYDVQQKEw1DaHJ5c2FsaXMtSVRTMQ8wDQYDVQQDEwZl bgfimtewggeima0gcsqgsib3dqebaquaa4ibdwawggekaoibaqdclu9av615d4m9 XeCN0yWtik1qDMNj2dnyo8qIy61VJuS1yBVsc4e+q2Hi+jWczb1kg5C819RQICMD qkpmgnlpwnf9g9zdtjabcs0wbe8qos/heudwwc7w3r9kdvfyu8xqahidyrmt4qm7 y/zvp/hamei0ojsfzwlkp5rq44iz4dynuzatdhzg8n8otiwq5ycpcepz0p7ogwu1 pqu7awmgcb+7det/eafry01s2vawnlf9i+oj5nyfb+yz/vizgvmvmjidwg5waj0t k6bjz9b8wvyjlc2cfl9utryo5h7c2bh1co77yjrc1gawcwr0yka0qm7nhy3zfr9p X1b6xOIJAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAIBzlE0PuI51b0UR/TK3LAlI Yso/F5pp4qnXgCYMgBG8Zt06WfHRR88ve7xun2FBPBSxpLGrwKwcsRbGyQqTfOgV 3/OZYg+ZZgHKcx7hlWp3oAdU622pxMedbgq9lDaAPhQfRBEby1KJDMNzNNDQLFmi 8ak+1oIyA2Fth4pBGK8og81EWx/F8Cs78vlXYhvnPVkr5qRiPRTIC+u3Bp09Ph6y MvlO/wfJ+WDa7si8pKW3FgpQYJSXhgURy50VOkfRlKY9slVBOPBhofpzPgJut3Pc 8M5XErJL0Wek4AkZg7kvM9JuKFJpvdLqkdbJfNFKfjAKEI3fpupmREPXMvAXgeU= -----END CERTIFICATE----- END hardwaresecuritymodulegroup:hsm:sluna:server >partition_passwd my_partition_password hardwaresecuritymodulegroup:hsm:sluna:server >save hardwaresecuritymodulegroup:hsm:sluna server > New object being created hardwaresecuritymodulegroup:hsm:sluna:server >remote_ip 1.1.1.13 hardwaresecuritymodulegroup:hsm:sluna:server >server_cert -- Please input the value for field server_cert (Enter END to terminate input): -----BEGIN CERTIFICATE----- MIIDKzCCAhOgAwIBAgIBADANBgkqhkiG9w0BAQsFADBZMQswCQYDVQQGEwJDQTEQ MA4GA1UECBMHT250YXJpbzEPMA0GA1UEBxMGT3R0YXdhMRYwFAYDVQQKEw1DaHJ5 c2fsaxmtsvrtmq8wdqydvqqdewzlbgfimtmwhhcnmtmxmde3mty0otu5whcnmjmx N7y9UMf7bfF9w0OrXt0gpUUTAUOpULXIiDCf+HzSRGVjhfsdjhfdjdjjjdjdjhw1 K5fTJ/s+1YurTZOGnSoBve3YQtdby4FAIo4UZpErGFCeCEihu31Do+i4ZCTuJHA= MDE5MTY0OTU5WjBZMQswCQYDVQQGEwJDQTEQMA4GA1UECBMHT250YXJpbzEPMA0G A1UEBxMGT3R0YXdhMRYwFAYDVQQKEw1DaHJ5c2FsaXMtSVRTMQ8wDQYDVQQDEwZl bgfimtmwggeima0gcsqgsib3dqebaquaa4ibdwawggekaoibaqcudvmynq9kxx02 9DTZmLCtXisbZI4jurnRI0OUuHhK+XIokNsdZTBSDKvkzVQieHMMl6Sw4kFxi1Fc 8SCSKeqDdbF72T+AFAL+qPqoCNxP0yKnklvx70aBIHryehhOIXsZinUkjcE75O8k abw2+imao/wayjwso61nsvw2i4/0glpqmduzmus0p0jivvt9lt5mbmsk8a1uhmer 9M24X9tmX6nYuclPtEiji970JaCNpbf37myAXV7g9oiGHHecmJ5jhKaMGyNXvi6A lj2xthgx7zg4c0s1/w97n20sc6h6hprq0wofugxmv0uskogoipvnwsrajjsy2jir 3Ob/y+bVAgMBAAEwDQYJKoZIhvcNAQELBQADggEBAF0+KnlxuP3C0OusYBCiqODg /3UB9wYoe8RAsjzNWRfzDZMBokLXvGfpSrcGaBnhOk4iRWRQjGdWrmYySwkoKm4j sktji305h2b4/qlf48ppkacz1qqynvfctvmfnjcuhsmh6amztdwujaw2kyps6dhr rtew+4w5yzb8ih8gcbo4ngm5tmhynkj++6wmespvxemro8uslwgiiropvx+3vyli AldyShOxC3au8czFeWK5sN7y9UMf7bfF9w0OrXt0gpUUTAUOpULXIiDCf+HzSRGV K5fTJ/s+1YurTZOGnSoBve3YQtdby4FAIo4UZpErGFCeCEihu31Do+i4ZCTuJHA= -----END CERTIFICATE----- END hardwaresecuritymodulegroup:hsm:sluna:server >partition_passwd my_partition_password hardwaresecuritymodulegroup:hsm:sluna:server >save Copyright 2018 Avi Networks, Inc. Page 6 of 12
hardwaresecuritymodulegroup:hsm:sluna >save hardwaresecuritymodulegroup:hsm >save hardwaresecuritymodulegroup >save In the above and below example, "my_partition_password" use the password provided by the SafeNet Network HSM administrator. Step 2: Register the Client with HSM Devices Follow these steps: 1. From the controller bash shell, copy the client certificate file (under /etc/luna/cert/client/aviclient.pem) to all the HSM devices. scp aviclient.pem admin@1.1.1.11: 2. Register the client on the HSM. ssh admin@1.1.1.11 admin@1.1.1.11's password: Last login: Thu May 12 19:52:00 2016 from 12.97.16.194 Luna SA 5.4.7-1 Command Line Shell - Copyright (c) 2001-2014 SafeNet, Inc. All rights reserved. [1.1.1.11] lunash: client register -c aviclient -h aviclient 'client register' successful. Command Result : 0 (Su [1.1.1.11] lunash: client assignpartition -c aviclient -p par43 'client assignpartition' successful. Command Resu [1.1.1.11] lunash: exit 3. Perform the above steps (1) and (2) for all HSM devices. 4. On the Avi Controller bash shell, the application ID must be opened before the Avi SE can communicate with the HSM. This can be done using the following command which will automatically be replicated to each Avi Controller in the cluster: <span style="font-weight: 400;">/etc/luna/bin/sautil -v -s 1 -i 1792:1793 -o -p my_partition_password</span> Copyright (C) 2009 SafeNet, Inc. All rights reserved. sautilis the property of SafeNet, Inc. and is provided to our customers for the purpose of diagnostic and development only. Any re-distribution of this program in whole or in part is a violation of the license agreement. Config file: /etc/chrystoki.conf. Will use application ID [1792:1793]. Application ID [1792:1793] opened. Open ok. Session opened. Handle 1 HSM Slot Number is 1. HSM Label is "ha1 ".WARNING: Application Id 1792:1793 has been opened for access. Thu remain open until all sessions associated with this Application Id are closed or until the access is explicitly closed. Note: In the step above, if an error message appears stating that the application is already open, you can close it using the following command. After closing it, reopen the application. Copyright 2018 Avi Networks, Inc. Page 7 of 12
/etc/luna/bin/sautil -v -s 1 -i 1792:1793 -c Copyright (C) 2009 SafeNet, Inc. All rights reserved. sautilis the property of SafeNet, Inc. and is provided to our customers for the purpose of diagnostic and development only. Any re-distribution of this program in whole or in part is a violation of the license agreement. Config file: /etc/chrystoki.conf. Close ok. Step 3: Setting Up HA Across HSM Devices (optional) The listslots command provides details about the HSM devices to be set up. The serial number provided in the output of this command is needed to set up HA across these devices. The haadmin subcommand under the vtl command provides these options. Once an HA group is created, additional members can be added using the addmember command, by providing the group number. The group number can be queried using vtl haadmin show. Also note there are subsequent configuration options for haadmin. More details about each of these commands can be found in the SafeNet documentation. /usr/safenet/lunaclient/bin/vtl listslots Number of slots: 5 The following slots were found: Slot # Description Label Serial # Status ========= ==================== =============================== ========== ============ slot #1 LunaNet Slot par43 156908040 Present slot #2 LunaNet Slot par40 156936072 Present slot #3 - - - Not present slot #4 - - - Not present slot #5 - - - Not present sudo /usr/safenet/lunaclient/bin/vtl haadmin newgroup -serialnum 156908040 -label my_ha_label -p my_partition_password sudo /usr/safenet/lunaclient/bin/vtl haadmin show ================ HA Global Configuration Settings =============== HA Proxy: disabled HA Auto Recovery: disabled Maximum Auto Recovery Retry: 0 Auto Recovery Poll Interval: 60 seconds HA Logging: enabled HA Log File: /tmp/haerrorlog.txt Maximum HA Log File Length: 262144 bytes Only Show HA Slots: no ================ HA Group and Member Information ================ Copyright 2018 Avi Networks, Inc. Page 8 of 12
HA Group Label: my_ha_label HA Group Number: 1156908040 HA Group Slot #: 6 Synchronization: enabled Group Members: 156908040 Standby members: Slot # Member S/N Member Label Status ====== ========== ============ ====== 1 156908040 par43 alive sudo /usr/safenet/lunaclient/bin/vtl haadmin addmember -group 1156908040 -serialnum 156936072 sudo /usr/safenet/lunaclient/bin/vtl haadmin HAOnly -enable sudo /usr/safenet/lunaclient/bin/vtl haadmin autorecovery -retry 500 sudo /usr/safenet/lunaclient/bin/vtl haadmin synchronize -group 1156908040 Once HA has been set up, update the configuration to reflect this change. From the Avi Controller shell run the following commands. This will be automatically synced to each Controller in the cluster: configure hardwaresecuritymodulegroup safenet-network-hsm-1 hardwaresecuritymodulegroup > hsm type hsm_type_safenet_luna hardwaresecuritymodulegroup:hsm >sluna hardwaresecuritymodulegroup:hsm:sluna >is_ha hardwaresecuritymodulegroup:hsm:sluna >save hardwaresecuritymodulegroup:hsm >save hardwaresecuritymodulegroup >save Alternatively, this can also be done in the web interface by selecting the HSM group. Step 4: Associate the HSM Group with an SE Group The HSM group must be added to the SE group that will be used by virtual service. Navigate to Infrastructure > Cloud > Default-Cloud > Service Engine Group > Default Group. Copyright 2018 Avi Networks, Inc. Page 9 of 12
This also can be configured using the Avi Controller CLI shell: configure serviceenginegroup Default-Group hardwaresecuritymodulegroup_ref safenet-network-hsm-1 In the above, replace "safenet" with the name you used when creating the HSM group. Step 5: Add the Application Certificates and Keys by Importing Them Use a browser to navigate to the Avi Controller?s management IP address. If Avi Vantage is deployed as a 3-node Controller cluster, navigate to the management IP address of the cluster. Use this procedure to import the private keys created using the SafeNet cmu/sautil utilities, and the associated certificates. More details about this can be found in the Appendix section of this KB. 1. Navigate to Templates > Security > SSL/TLS Certificates, and click Create > Application Certificate. Copyright 2018 Avi Networks, Inc. Page 10 of 12
2. Enter a name for the certificate definition. 3. Click Import. 4. Prepare to import the private key for the server certificate. 1. Above the Key field, in the Certificate Information section, select Paste text (to copy-and-paste the certificate text directly in the web interface) or Upload File. 2. If the key file is secured by a passphrase, enter it in the Key Passphrase field. 3. Paste the key file (if copy-and-pasting) or navigate to the location of the file (if uploading). 5. Prepare to import the server certificate: 1. Above the Certificate field, select Paste text or Upload File. 2. Paste the key file (if copy-and-pasting) or navigate to the location of the file (if uploading). 6. Click Validate. Avi Vantage checks the key and certificate files to ensure they are valid. Step 6: Enable HSM Support on a Virtual Service 1. In the Controller web management interface, navigate to Applications > Virtual Services. 2. Click New or Edit. 3. If configuring a new virtual service, enter the name of the VIP. 4. Select the HSM certificate from the SSL Certificate drop-down list. 5. Enter the virtual service name and VIP address. 6. In the Service Port section, enable SSL. 7. Click Advanced. On the Advanced page, select the SE group to which the HSM group was added. 8. Click Save. Copyright 2018 Avi Networks, Inc. Page 11 of 12
The virtual service is now ready to handle SSL/TLS traffic using the encryption/decryption services of the SafeNet Network HSM device. Appendix: Avi Vantage CLI Commands to Create Key and Sign Certificates (When Using SafeNet HSM) As an alternative to using the web interface, the CLI can be used to create a public/private key pair on the HSM and sign certificates. To generate 2048-bit RSA keys: <br> >/usr/safenet/lunaclient/bin/cmu generatekeypair -slot 1 -keytype RSA - modulusbits=2048 -publicexp=65537 -labelpublic=my-public-key -labelprivate=my-private-key - sign=true -verify=true -encrypt=true -decrypt=true -wrap=false -unwrap=false - extractable=false -modifiable=false<br> To download the fake private key: <br> >/etc/luna/bin/sautil -s 1 -i 1792:1793 -a 0:RSA -f /tmp/my-pkey.pem<br> To generate a self-signed certificate: <br> >openssl req -engine gem -key /tmp/my-pkey.pem -new -x509 -days 365 -out /tmp/my-cert. crt<br> To generate ECDSA keys: <br> >openssl ecparam -out ecparam.pem -name prime256v1<br> >/etc/luna/bin/sautil -v -s 1 - i 1792:1793 -m OID_:ecparam.pem -f my-ecdsa-key.pem<br> To generate a self-signed certificate: <br> >openssl req -engine gem -key my-ecdsa-key.pem -new -x509 -days 365 -out my-cert-1. crt<br> Copyright 2018 Avi Networks, Inc. Page 12 of 12