View SoftHSMv2 log information
mainsyslog or the Windows event log. The logging level is controlled within the softhsm2.conf file. Each log entry includes the source file name and line number for debugging.repository·main·Indexed 21 days ago
https://github.com/softhsm/softhsmv2A software implementation of a generic cryptographic device providing a PKCS#11 interface. SoftHSMv2 allows developers to simulate Hardware Security Modules (HSMs) for cryptographic key generation and signing without physical hardware. It supports multiple cryptographic backends including OpenSSL and Botan, and provides tools for token initialization, migration, and backup.
syslog or the Windows event log. The logging level is controlled within the softhsm2.conf file. Each log entry includes the source file name and line number for debugging.SoftHSMv2 supports two primary backends for storing token objects: the File backend and the Database (DB) backend.
Performance Tip: For high-speed requirements using the database backend, consider copying the entire token database to a ramdisk. Note that this should only be used if the token is not being modified, as a power cycle will wipe the ramdisk.
SoftHSMv2 uses a configuration file to define its behavior, such as the location of the token directory.
/etc/softhsm2.confSOFTHSM2_CONF environment variable.Before using SoftHSM, ensure the token directory defined in your configuration file exists.
Example: Using a custom configuration file
export SOFTHSM2_CONF=/home/user/config.file
mkdir <token_dir_from_config>For detailed configuration options, use the command man softhsm2.conf.
export SOFTHSM2_CONF=/home/user/config.file
mkdir <token_dir>softhsm2.conf file. To perform a backup, simply perform a regular file copy of that directory.To build SoftHSMv2 on Windows, you must prepare your environment with Visual Studio, CMake, and the Microsoft C/C++ dependency manager (vcpkg). This process involves cloning the necessary repositories, bootstrapping vcpkg, installing specific dependencies for both 32-bit (x86) and 64-bit (x64) architectures, and then using CMake to configure and compile the project.
# Example workflow summary
set VCPKG_HOME=C:\Projects\vcpkg
set SOFTHSM_HOME=C:\Projects\SoftHSMv2
# ... install dependencies via vcpkg ...
# ... configure via cmake ...
# ... build via cmake --build ...Once configured, compile the source code using make targeting the build directory:
make -C buildBefore starting the build process, create the following directory structure on your C: drive:
C:\build\bin\ for compiled binaries and installed libraries.C:\build\src\ for source code archives.mkdir C:\build\bin\
mkdir C:\build\src\To install the compiled library onto your system, run the install command with sudo from the parent directory of the build folder:
cd ..
sudo make -C build installOpenSSL 1.1.0a can be used as a crypto backend. Download the archive and signature into C:\build\src\ and verify with gpg.
C:\build\src\openssl-1.1.0a-x86.--prefix=C:\build\bin\openssl-1.1.0a-x86 --openssldir=C:\build\bin\openssl-1.1.0a-x86\ssl no-shared.C:\build\src\openssl-1.1.0a-x64.--prefix=C:\build\bin\openssl-1.1.0a-x64 --openssldir=C:\build\bin\openssl-1.1.0a-x64\ssl no-shared and use vcvarsall.bat amd64.# 32-bit Example
cd C:\build\src\openssl-1.1.0a-x86
set PATH=%PATH%;C:\nasm
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
perl Configure VC-WIN32 --prefix=C:\build\bin\openssl-1.1.0a-x86 --openssldir=C:\build\bin\openssl-1.1.0a-x86\ssl no-shared
nmake
nmake test
nmake install
# 64-bit Example
cd C:\build\src\openssl-1.1.0a-x64
set PATH=%PATH%;C:\nasm
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" amd64
perl Configure VC-WIN64A --prefix=C:\build\bin\openssl-1.1.0a-x64 --openssldir=C:\build\bin\openssl-1.1.0a-x64\ssl no-shared
nmake
nmake test
nmake installAfter cloning the repository and installing dependencies, follow these steps to build and verify the installation.
git clone https://github.com/opendnssec/SoftHSMv2.git
cd SoftHSMv2sh ./autogen.sh--with-objectstore-backend-db flag to enable the SQLite database backend. It is recommended to use brew --prefix to ensure compatibility across Intel and Apple Silicon architectures:./configure --with-objectstore-backend-db \
--with-openssl=$(brew --prefix openssl@3) \
--with-sqlite3=$(brew --prefix sqlite)Troubleshooting: If you encounter "Can't find OpenSSL headers", verify that the path provided to --with-openssl contains include/openssl/ssl.h.
Compiler issues: If compilers are not found, explicitly export the Xcode paths:
export CC="xcrun gcc"
export CPP="xcrun cpp"
export CXX="xcrun g++"
./configure --with-objectstore-backend-db --with-openssl=$(brew --prefix openssl@3) --with-sqlite3=$(brew --prefix sqlite)makemake checkTo run only the PKCS#11 test cases:
make -C src/lib/test checkmake
make checkTo build SoftHSMv2 from source, you must first prepare the configuration scripts using Autotools.
Prerequisites:
automake, autoconf, libtool, libtool-ltdl-devel (on RHEL/CentOS/Fedora), and pkg-config.Botan (>= 2.6.0 recommended for performance) or OpenSSL (>= 1.0.0).--with-migrate) or using the database object store (--with-objectstore-backend-db), SQLite3 (>= 3.4.2) is required.CppUnit is required.Steps:
sh autogen.sh to generate configuration scripts../configure with desired options.make to compile.sudo make install to install the library.sh autogen.sh
./configure
make
sudo make installUse CMake to configure the build environment. You must specify the generator, architecture, the vcpkg toolchain file, and the installation prefix. You can choose between different crypto backends (openssl or botan) and object store backends.
# Configure 32-bit build
mkdir %SOFTHSM_HOME%\tmp32
cd %SOFTHSM_HOME%\tmp32
cmake .. -G "Visual Studio 15 2017" -A Win32 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_HOME%\scripts\buildsystems\vcpkg.cmake -DCMAKE_INSTALL_PREFIX=%SOFTHSM_HOME%\out32 -DBUILD_TESTS=ON -DWITH_CRYPTO_BACKEND=openssl -DWITH_OBJECTSTORE_BACKEND_DB=OFF
# Configure 64-bit build
mkdir %SOFTHSM_HOME%\tmp64
cd %SOFTHSM_HOME%\tmp64
cmake .. -G "Visual Studio 15 2017" -A x64 -DCMAKE_TOOLCHAIN_FILE=%VCPKG_HOME%\scripts\buildsystems\vcpkg.cmake -DCMAKE_INSTALL_PREFIX=%SOFTHSM_HOME%\out64 -DBUILD_TESTS=ON -DWITH_CRYPTO_BACKEND=botan -DWITH_OBJECTSTORE_BACKEND_DB=ON