- Set FXPKCS11 environment variables.
- Explore some OpenSSL Provider 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 by using the pkcs11-tool available from the OpenSC ( github.com/OpenSC/OpenSC) suite to generate keys. On both DEB-based and RPM-based distributions, the package is calledopensc.
In a terminal, execute the following command usingpkcs11-tool to generate and store a new key pair on the Vectera Plus:
Shell
Enter the password of the identity configured in the
fxpkcs11.cfg file when prompted for the User PIN.If the command executes successfully, the generated keys will appear in the output, as shown in the following example:The command creates the following keys, which the next section uses to test the OpenSSL commands:
Shell
- A private RSA 2048 key with asymmetric decrypt and sign usage
- A public RSA 2048 key with asymmetric encrypt and verify usage.
OpenSSL example commands
The following OpenSSL example commands use the keys created on the Vectera Plus in the previous section. All commands specify the PKCS11 OpenSSL provider and the provider path. This section does not provide an exhaustive list of OpenSSL commands that you can run using the PKCS11 OpenSSL Provider. Instead, it gives a few examples of use cases and confirms everything was configured 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 to a file from the HSM:Shell
If the command succeeds, you should see the
myrsa2048pubkey.pem file was generated, which contains the public key.Example 2: Encrypt and decrypt data
Follow these steps to encrypt data using the public key and decrypt it with the private key stored on the HSM:In a terminal, run the following command to generate a file,
clear_data, containing random ASCII data:Shell
Encrypt the
clear_data file using the HSM’s public key and output the results to a file, encrypted_data.Shell
Decrypt the
encrypted_data file using the HSM’s private key and output the results to a file, decrypted_data.Shell
Example 3: Sign a file and verify the signature
Perform the following step to sign a data file using the HSM’s private key and verify the signature by using the HSM’s public key:Sign the
clear_data file using the HSM’s private key and output the signature to a file, clear_data.sig.Shell
Example 4: Create a self-signed Root CA
Perform the following steps to create a self-signed Root CA:Example 5: Generate a CSR
Perform the following steps to generate a CSR:Example 6: Sign a CSR
Execute the following command to sign the previously generated CSR by using the HSM-stored private key and the self-signed CA generated earlier:Shell
A successful command execution will generate the
signed-client-cert.pem file, containing the signed certificate. Also, a serial number file, ssl-ca-cert.srl, is created to track the certificate’s serial number for future CA operations.
