Description:
When opening a PKCS#11 session in read-write (RW) mode, there may be instances where the token does not support RW sessions, leading to errors. This issue proposes the addition of a pre-check to verify that the token has the necessary capability (e.g., CKF_WRITE_PROTECTED) before attempting to open a session in RW mode.
Proposed Behavior:
- Before opening a session in RW mode, verify the token’s flags to confirm support for RW sessions.
- If the token does not support RW sessions, open it in read-only mode.