Description
On Windows, an exclusive transaction from SCardBeginTransaction
is only usable for 5 seconds. After this timeout, all operations will result with SCARD_W_RESET_CARD
- "The smart card has been reset, so any shared state information is invalid.".
From the Winscard API docs:
If a transaction is held on the card for more than five seconds with no operations happening on that card, then the card is reset. Calling any of the Smart Card and Reader Access Functions or Direct Card Access Functions on the card that is transacted results in the timer being reset to continue allowing the transaction to be used.
The SCardBeginTransaction function is a smart card and reader access function. For more information about other access functions, see Smart Card and Reader Access Functions.
To resolve this, the caller must refresh the transaction with SCardReconnect
.
From the Winscard API docs:
The SCardReconnect function reestablishes an existing connection between the calling application and a smart card. This function moves a card handle from direct access to general access, or acknowledges and clears an error condition that is preventing further access to the card.
I've validated that this approach works and am working on preparing a PR.
Related downstream issues: