Prerequisites
Xcode command-line tools
You need a C++ compiler. If you have Xcode installed, it is already available. To check where Xcode keeps the compiler:Homebrew
The libraries bundled with macOS are too old for reliable builds. Install Homebrew to get current versions:Install dependencies
Homebrew installs these libraries under
/usr/local/opt/ (Intel) or /opt/homebrew/opt/ (Apple Silicon) to avoid conflicting with Apple’s system copies. You must pass the Homebrew paths to configure explicitly — see the configure step below.Homebrew renames
libtool to glibtool and libtoolize to glibtoolize to avoid conflicts with Apple’s own libtool. The autogen.sh script generates its own libtool wrapper, so this renaming does not cause problems in practice.Build and install
Configure
You must pass the Homebrew-managed paths to OpenSSL and SQLite so the configure script can find them:On Apple Silicon (M1/M2/M3), Homebrew installs to If the compilers were not picked up automatically, set them before running configure:
/opt/homebrew instead:Default install path
The PKCS#11 library is installed to:/etc/softhsm2.conf. Override it with the SOFTHSM2_CONF environment variable:
Object store backends
SoftHSM supports two storage backends for token objects:| Backend | Configure flag | Notes |
|---|---|---|
| File (default) | (none) | One file per object. Fastest option. |
| SQLite3 database | --with-objectstore-backend-db | Single sqlite3.db file per token. Better for large key stores. |
Switching to the database backend for testing
After enabling--with-objectstore-backend-db, update the test configuration files:
src/lib/test/softhsm2.conf:
src/lib/test/softhsm2-alt.conf:
sqlite3.db inside the token subdirectories:
Performance notes
The SQLite3 database backend is designed for deployments with large numbers of keys (more than 100,000). Its advantages are:- Single-file token store — avoids file-system limits on the number of files per directory.
- Lower memory usage — loads object attributes on demand, using roughly 20% less memory than the file backend.
- Selective loading — designed to allow querying a subset of objects (selective query support is not yet fully implemented).
Known issues and gotchas
- libtool naming: Homebrew renames
libtooltoglibtoolto avoid conflicting with Apple’s libtool. Theautogen.shscript handles this automatically. - Homebrew path differences: The prefix changed from
/usr/localto/opt/homebrewon Apple Silicon. If configure cannot find a library, checkbrew --prefix <package>for the correct path. xcrunwrappers: If configure fails to locate the compiler, useexport CC="xcrun gcc"(and the equivalent forCPPandCXX) to force use of the Xcode-bundled toolchain.