Generate Client Key and Certificate on Utimaco HSM

  1. Generate client key using the p11tool2 command.

›_ Console

> p11tool2 slot=0 LoginUser=ask 

PubKeyAttr=CKA_LABEL=”OpenVPNPublicKey”,CKA_ID=0x45 

PrvKeyAttr=CKA_LABEL=”OpenVPNPrivateKey”,CKA_ID=0x45 GenerateKeyPair=RSA 

Provide the slot PIN when prompted.

image-3284435044-1.jpg

Generate RSA key command output

  1. Generate certificate request for client. Provide the slot PIN when prompted.

›_ Console

> openssl req -engine pkcs11 -new -key 

“pkcs11:token=OpenVPNToken;object=OpenVPNPrivateKey” -keyform engine -out OpenVPNClient.req 
image-3284435044-2.jpg

Certificate request command output

  1. Copy the OpenVPNClient.req file to C:\Program Files\OpenVPN\easy-rsa\pki\reqs.

  2. Go into directory C:\Program Files\OpenVPN\easy-rsa and start easy-rsa shell.

›_ Console

> EasyRSA-Start.bat 
image-3284435044-3.jpg

EasyRSA shell

  1. Sign the client CSR.

›_ Console

>./easyrsa sign-req client OpenVPNClient 
image-3284435044-4.jpg

Client CSR signing

image-3284435044-5.jpg

Client CSR signing

  1. To import the certificate into HSM, convert the certificate file (.crt) into .der format using the below command.

›_ Console

> openssl x509 -outform der -in OpenVPNClient.crt -out OpenVPNClient.der 
image-3284435044-6.jpg

Convert certificate into .der format

  1. Import certificate into HSM using the command below. Provide slot PIN when prompted.

›_ Console

> p11tool2 slot=0 LoginUser=ask 

CertAttr=CKA_LABEL=”OpenVPNClientCert”,CKA_ID=0x45,CKA_PRIVATE=False  

PubKeyAttr=CKA_LABEL=”OpenVPNClientCertPublicKey”,CKA_ID=0x45 ImportCert=OpenVPNClient.der 
image-3284435044-7.jpg

Import certificate command output

  1. List objects of HSM using the command below. Provide the slot PIN when prompted.

›_ Console

> p11tool2 slot=0 LoginUser=ask ListObjects 
image-3284435044-8.jpg

List objects command output

image-3284435044-9.jpg

List objects command output