Strip sql:/dbm: prefix from NSS configdir - #219
Open
MarkAtwood wants to merge 1 commit into
Open
MarkAtwood wants to merge 1 commit into
MarkAtwood wants to merge 1 commit into
Conversation
NSS passes the database directory to C_Initialize with its database
type prefix when the application uses one ("certutil -d sql:/path",
Chromium's sql:$HOME/.pki/nssdb). The prefix became part of the token
store path, so no token could be stored and C_InitPIN failed with
CKR_FUNCTION_FAILED. Strip the sql:, dbm: and extern: prefixes.
Add tests/nss_configdir_prefix_test.c.
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused fix is correct and covered, with only a minor test skip-reporting convention remaining.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Strips NSS database-type prefixes before configuring wolfPKCS11’s token-store directory.
Changes:
- Handles
sql:,dbm:, andextern:prefixes. - Adds regression coverage for prefixed and unprefixed paths.
- Registers the test with Automake.
| File | Description |
|---|---|
src/wolfpkcs11.c |
Strips NSS database prefixes. |
tests/nss_configdir_prefix_test.c |
Tests token storage paths. |
tests/include.am |
Builds and runs the regression test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| (void)argc; | ||
| (void)argv; | ||
| printf("NSS build with a token store not configured, skipping test\n"); | ||
| return 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

NSS passes the token its db location with a type prefix:
sql:/path,dbm:/pathorextern:/path(e.g.certutil -d sql:/path, Chromium'ssql:$HOME/.pki/nssdb). wolfPKCS11 uses that string as the directory, so the store ends up looking for a directory namedsql:/path, which doesn't exist. Nothing gets written; C_InitToken and C_InitPIN fail andcertutil -Nfails.This strips the prefix before using the path. Upstream's NSS CI uses
certutil -d /pathwithout a prefix, so CI never hit it.Test:
nss_configdir_prefix_test. Fails on master, passes with the fix.