Skip to content

Conversation

@olszomal
Copy link
Collaborator

@olszomal olszomal commented Apr 11, 2025

The call to ERR_clear_error() in the CRYPTOKI_checkerr macro has been removed. Its presence was unintentionally discarding important error information in multi-step object fetching scenarios within the PKCS#11 provider.

When expected_type is not specified, the store implementation attempts to load a private key, then a public key, and finally a certificate. If the first attempt (e.g., loading a private key) fails due to an incorrect PIN, the corresponding error (such as CKR_PIN_INCORRECT) is pushed onto the OpenSSL error queue. Subsequent attempts clear this queue via ERR_clear_error(), effectively masking the root cause.

Preserving the error queue allows higher-level code to accurately report the original failure reason and improving diagnostics.

@mtrojnar mtrojnar merged commit 69a5133 into OpenSC:master Apr 22, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants