-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #74: plugout the last device will raise an smartcard.Exceptions #93
Conversation
…rd.Exceptions.ListReadersException error,-2146435043/8010001D
Can you document why each change is needed? The problem is Windows specific. I would not like to have regression in Unix. |
I tested on Windows 10 + pyscard 1.9.9 + two sample codes: sample_MonitorCards.py and sample_MonitorReaders.py. I can't reproduce the problem.
|
@leileigong Any comment to add? Without your feedback I will just close this PR. |
@LudovicRousseau this bug still exists on pyscard 2.0.0 can you merge my fix commit 2e9cb0 |
@leileigong before I fix a problem I need to be able to reproduce it, or at least to understand it. Please provide a sample code and a detailed sequence of actions to reproduce the problem? |
@LudovicRousseau step 1. run the sample code sample_MonitorCards.py) on WIndows 10. step2 plugin the smartcard. step3 then plugout the smartcard, will got an error.
|
I installed miniconda3 on Windows 10 20H2. Then I installed PySCard 2.0.0 using pip.
It is strange I see a new "smart card inserted" event. But I do NOT get a crash or exception.
Can you also test with miniconda on your side? |
@LudovicRousseau How do install and test with miniconda? is it miniconda version 3? |
I guess I face a variant, with a Windows SSH PIV agent in development : The software handles the card with simply :
It happens when the reader is disconnected after a first initial pyscard session. Whatever the disconnection is brutal (during data exchange), gentle (operations finished), or after a nicely deletion of the card connection object, the Windows software can't reconnect to the smartcard and throws this error. Annoying, since some USB keys as the Yubico act as a full reader and not a single card, and when user removes that, Windows stops the card manager, the source of many issues with pyscard, and this is exacerbated with these kind of USB dongles. Let me know if you want a separate issue. |
@antonio-fr your code is waiting for a card insertion. Or am I mistaken? As I wrote I was not able to reproduce the problem on my Windows 10 system. |
On Windows, when the last reader is removed the PC/SC manager is stopped. A PC/SC call will receive SCARD_E_SERVICE_STOPPED. The idea here is to renew the PC/SC context in getReaderNames(). Thanks to Lemon Gong for the patch "fix #74: plugout the last device will raise an smartcard.Exceptions #93" https://github.com/LudovicRousseau/pyscard/pull/93/files This change should also fix: - "Plugout an PCSC device will raise ListReadersException(hresult) on windows #74" #74 - "Windows smartcard service is started only once #114" #114
I applied 2 of your 3 patches. Thanks and sorry for the delay. I don't understand what problem the patch for |
I released version 2.0.1. https://ludovicrousseau.blogspot.com/2021/06/pyscard-201-released.html |
@leileigong I think your change in d5cf89c is bogus. I reverted the change in my https://github.com/LudovicRousseau/pyscard-debug fork. Can you check on your side the problem on Windows is still fixed? |
I handled the last reader removal in LudovicRousseau/pyscard-debug@5b43ef5 |
Fixed released in version 2.0.2 |
the problem #74 still not resolved yet.
smartcard.Exceptions.ListReadersException: Failed to list readers: -2146435043/8010001D
raise ListReadersException(hresult)
smartcard.Exceptions.ListReadersException: Failed to list readers: ÖÇÄÜż¨×ĘÔ´ąÜŔíĆ÷δÔËĐСŁ (0x-7FEFFFE3) by
getReaderNames