objectstore.backend configuration option.
File backend
The file backend is the default. Each token is stored as a subdirectory insidedirectories.tokendir, and each PKCS#11 object within a token is stored as a separate file.
Directory layout
UUID::newUUID() at object creation). Each .object file is accompanied by a .lock file used for synchronisation between concurrent accessors.
Example
Configuration
Characteristics
- No additional build dependencies.
- Human-inspectable on disk (though the file format is binary).
- Scales well for small to moderate numbers of objects.
- Concurrent access from multiple processes relies on advisory file locking. Files are flushed before locks are released.
SQLite3 database backend
Thedb backend stores all objects for a token in a single SQLite3 database file (sqlite3.db) inside the token directory. This backend must be enabled at build time.
Build requirement
Directory layout
Configuration
Characteristics
- Requires SQLite3 at build time and at runtime.
- Transactional writes; atomic updates across multiple attributes.
- SQLite3 busy timeout is set to 3 minutes to handle contention under concurrent access.
- Generally faster for tokens with a large number of objects, due to indexed lookups.
- A single database file is easier to back up than a directory tree of individual object files.
If you switch
objectstore.backend on an existing installation, the existing tokens will not be readable by the new backend. Initialise new tokens after changing the backend, or migrate data beforehand.Controlling file permissions with objectstore.umask
Regardless of which backend is used, SoftHSM applies an additional umask when creating files and directories in the token store. This is configured with objectstore.umask.
Choosing a backend
| File | DB (SQLite3) | |
|---|---|---|
| Build dependency | None | SQLite3 |
| Per-object isolation | Yes | No (single file) |
| Transactional writes | No (per-file flush) | Yes |
| Large token performance | Moderate | Better |
| Backup simplicity | Directory copy | Single file copy |
| Windows support | Yes | Yes (since 2.7.0) |
| Default | Yes | No |