Skip to main content
Perform the following tasks to test OpenSSL engine:
  1. Set FXPKCS11 environment variables.
  2. Explore some OpenSSL Engine examples.

Set FXPKCS11 environment variables

In a terminal, run the following sequence of commands to set the required FXPKCS11 environment variables:
Shell

Create a key pair

Perform the following steps to create a key pair on the Vectera Plus by using pkcs11-tool:
1
In a terminal, run the following command to use pkcs11-tool to create a new key pair on the Vectera Plus:
Shell
2
Enter the password of the identity configured in the fxpkcs11.cfg file when prompted for the User PIN.
If the command succeeds, the keys display in the output, as shown in the following example:
Shell
The command creates the following keys, which the next section uses in the test OpenSSL commands:
  • A private RSA 2048 key with asymmetric sign and verify usage
  • A public RSA 2048 key with verify usage.

OpenSSL example commands

Most of the following OpenSSL example commands use the keys created on the Vectera Plus in the previous section. All the commands that use the keys created on the HSM specify the PKCS11 OpenSSL engine. This section does not provide an exhaustive list of OpenSSL commands that you can run by using the PKCS11 OpenSSL Engine. Instead, it provides a few examples of use cases and confirms that you configured everything correctly. Refer to the OpenSSL documentation (www.openssl.org/docs/) for the full list of compatible commands.

Example 1: Output the public key

In a terminal, run the following command to output the public key from the HSM:
Shell
If the command succeeds, you should see output similar to the following example:
Shell

Example 2: Encrypt and decrypt data

Perform the following steps to encrypt data with the public key and decrypt with the HSM stored private key:
1
In a terminal, run the following command to generate a file, clear_data, containing random ASCII data:
Shell
2
Retrieve the public key from the HSM.
Shell
3
Encrypt the clear_data file by using the public key retrieved from the HSM and output the results to a file, encrypted_data.
Shell
4
Decrypt the encrypted_data file by using the HSM stored private key and output the results to a file, clear_ data2.
Shell
5
Confirm that the contents of clear_data and clear_data2 files are identical.
Shell

Example 3: Sign a file and verify the signature

Perform the following step to sign a data file using the HSM stored private key and verify the signature by using the public key:
1
Sign the clear_data file by using the HSM stored private key and output the signature to a file, clear_data.sig.
Shell
2
Verify the signature by using the public key.
Shell
A message should display on the screen confirming that the signature was verified successfully.

Example 4: Create a self-signed Root CA

Perform the following steps to create a self-signed Root CA:
1
Generate a self-signed CA certificate with the HSM stored private key.
Shell
2
When prompted, enter information about the self-signed CA certificate.
After you enter the information, the command creates the follwoing file: ssl-ca-cert.pem.

Example 5: Generate a CSR

Perform the following steps to generate a CSR:
1
Generate a CSR with the HSM stored private key.
Shell
2
When prompted, enter information about the certificate.
After you enter the information, the command creates the following file: ssl-client-cert-req.pem.

Example 6: Sign a CSR

Execute the following command to sign a CSR by using the HSM-stored private key:
Shell
The command outputs the signed certificate to the signed-client-cert.pem file.