fix: restore compatibility with libp11 0.4.13 #36
+12
−5
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.
This module is no longer compatible with the openssl pkcs11 engine since libp11 version 0.4.13.
Compatibility between this module and libp11 has been broken since OpenSC/libp11@da8cd1f.
Root cause
This change introduced some automatic clearing of keys when no more valid sessions exist. However, since checking if a session is valid is done by checking if
C_GetSessionInfo
returnsCKR_OK
1 this currently always marks all sessions as invalid asC_GetSessionInfo
always returnsCKR_FUNCTION_NOT_SUPPORTED
.Therefore keys get cleared too early, causing undefined behaviour.
Initially this caused a segfault and since OpenSC/libp11@7f6eba0 the visible behaviour of the bug changed to instead result in errors of the form:
Likely due to the new
key->object_class == CKO_PRIVATE_KEY
check always failing on cleared keys.Fix
This PR restores the old behaviour by now always returning
CKR_OK
inC_GetSessionInfo
.Disclaimer: I lack the in-depth understanding of pkcs11 modules to properly asses wether implementing
C_GetSessionInfo
this way may cause other issues.Footnotes
https://github.com/OpenSC/libp11/blob/6d669183c7b241ce47ecce28744837ad92814f5c/src/p11_slot.c#L156 ↩