Skip to content

Fix crash when closing sessions with vendor-specific user types#231

Open
akaloti wants to merge 1 commit into
pyauth:masterfrom
akaloti:fix/custom-user-support
Open

Fix crash when closing sessions with vendor-specific user types#231
akaloti wants to merge 1 commit into
pyauth:masterfrom
akaloti:fix/custom-user-support

Conversation

@akaloti

@akaloti akaloti commented Jun 16, 2026

Copy link
Copy Markdown

Fix #230

In the current version of this package, when using a custom user such as the Crypto User -- represented by value 0x80000001 -- on Thales Luna HSM 7, we run into problems when closing a session because:

  • The Session.close() method calls Session.user_type(). (Both methods are defined in pkcs11/_pkcs11.pyx.)
  • Session.user_type() then calls UserType().
  • UserType(), defined in pkcs11/constants.py, crashes because the custom user value 0x80000001 does not match NOBODY (999), SO (0), or USER (1).

This PR fixes the problem by avoiding the indirect call to UserType() in Session.close(). It also updates Session.user_type() to not crash if the user type is a custom user.

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.

Session crashes when using vendor defined user type in open

1 participant