Skip to main content

Install and configure pkcs11-provider by Latchset

Guide to install and configure pkcs11-provider for OpenSSL, targeting developers.
This section describes how to install and configure pkcs11-provider from Latchset for the OpenSSL library. The following list provides an overview of pkcs11-provider library:
LibraryDescription
pkcs11-providerAn OpenSSL 3.x cryptographic provider that enables access to cryptographic tokens—such as smart cards and Hardware Security Modules (HSMs)—through the standard PKCS#11 API. It acts as a bridge between OpenSSL’s provider-based architecture and any PKCS#11-compliant module.

Install pkcs11-provider

Instructions for installing pkcs11-provider depend on the Linux version being used. Perform the following instructions to install pkcs11-provider on the supported operating systems:

Ubuntu or Debian

Perform the following steps to install pkcs11-provider on Ubuntu 24.04 or Debian 13:
While apt can install the minimum required version (v0.3) of pkcs11-provider, Futurex recommends compiling it from source so that you use the latest version. This avoids compatibility issues and gives you access to the most recent features and bug fixes.
1
Install Prerequisites
Shell
2
Build and change directories into a /src directory (recommended to keep source builds organized)
Shell
3
Clone the pkcs11-provider repository
Shell
4
Build with Meson
Shell
5
Install the provider
Shell
When this command is finished, take note of where the pkcs11.so file was installed. The path will be needed for the openssl.cnf file later.

Red Hat or CentOS

In a terminal, run the following sequence of commands to install pkcs11-provider on Red Hat or CentOS:
1
Install Prerequisites
Shell
If the system does not support dnf, use yum instead.
2
Change into a /usr/local/src directory (recommended to keep source builds organized)
Shell
3
Clone the Repository
Shell
4
Build with Meson
Shell
5
Install the provider
Shell
When this command is finished, take note of where the pkcs11.so file was installed. The path will be needed for the openssl.cnf file later.

Edit the OpenSSL configuration file

Perform the following steps to edit the OpenSSL configuration file for Ubuntu or Debian-based Linux distributions and Red Hat or CentOS-based distributions:
1
Run the following command to determine the location of the global OpenSSL configuration file for the logged-in user:
Shell
2
Open the openssl.cnf file in a text editor with root privileges.
3
Add the following line at the top of the file, before any sections, if it is not already present:
None
4
Add the following text, based on your operating system, at the bottom of the file after modifying the module and pkcs11-module-path:
None
If you need automatic logging to the token, specify the PIN by adding the following line:pkcs11-module-token-pin = file:/path/to/filewithpin.txtThe file referenced should contain just the PIN.
5
Test if OpenSSL successfully loaded the provider.
Shell
If successful, both default and pkcs11 should be listed under providers.