You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromykman.deviceimportlist_all_devices, scan_devicesfromyubikit.core.smartcardimportSmartCardConnectionfromtimeimportsleephandled_serials=set() # Keep track of YubiKeys we've already handled.state=NonewhileTrue: # Run this until we stop the script with Ctrl+Cpids, new_state=scan_devices()
ifnew_state!=state:
state=new_state# State has changedfordevice, infoinlist_all_devices():
ifinfo.serialnotinhandled_serials: # Unhandled YubiKeyprint(f"Programming YubiKey with serial: {info.serial}")
... # Do something with the device here.handled_serials.add(info.serial)
else:
sleep(1.0) # No change, sleep for 1 second.
Wait a second for it to be detected, then unplug the Yubikey at any point.
Expected result
The code to only print the print() message, nothing else.
Actual results and logs
Right when I unplug the yubikey:
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/ykman/device.py", line 168, in add
with dev.open_connection(conn_type) as conn:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ykman/pcsc/__init__.py", line 88, in open_connection
return self._open_smartcard_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ykman/pcsc/__init__.py", line 100, in _open_smartcard_connection
raise e
File "/usr/lib/python3.11/site-packages/ykman/pcsc/__init__.py", line 96, in _open_smartcard_connection
return ScardSmartCardConnection(self.reader.createConnection())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ykman/pcsc/__init__.py", line 106, in __init__
connection.connect()
File "/usr/lib/python3.11/site-packages/smartcard/CardConnectionDecorator.py", line 54, in connect
self.component.connect(protocol, mode, disposition)
File "/usr/lib/python3.11/site-packages/smartcard/pcsc/PCSCCardConnection.py", line 122, in connect
raise CardConnectionException(
smartcard.Exceptions.CardConnectionException: Unable to connect with protocol: T0 or T1. Reader is unavailable.
Failed opening device
Traceback (most recent call last):
File "/usr/lib/python3.11/site-packages/ykman/device.py", line 168, in add
with dev.open_connection(conn_type) as conn:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ykman/pcsc/__init__.py", line 88, in open_connection
return self._open_smartcard_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ykman/pcsc/__init__.py", line 100, in _open_smartcard_connection
raise e
File "/usr/lib/python3.11/site-packages/ykman/pcsc/__init__.py", line 96, in _open_smartcard_connection
return ScardSmartCardConnection(self.reader.createConnection())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/ykman/pcsc/__init__.py", line 106, in __init__
connection.connect()
File "/usr/lib/python3.11/site-packages/smartcard/CardConnectionDecorator.py", line 54, in connect
self.component.connect(protocol, mode, disposition)
File "/usr/lib/python3.11/site-packages/smartcard/pcsc/PCSCCardConnection.py", line 122, in connect
raise CardConnectionException(
smartcard.Exceptions.CardConnectionException: Unable to connect with protocol: T0 or T1. Reader is unavailable.
Other info
The weird thing for me is that this is triggered "elsewhere"? My code is never referenced in the stack trace. So I have no idea how to mute this with a try/except.
pacman -S ykman
Steps to reproduce
Install
ykman
, run for instance:Wait a second for it to be detected, then unplug the Yubikey at any point.
Expected result
The code to only print the
print()
message, nothing else.Actual results and logs
Right when I unplug the yubikey:
Other info
The weird thing for me is that this is triggered "elsewhere"? My code is never referenced in the stack trace. So I have no idea how to mute this with a
try/except
.My
/etc/opensc.conf
file:The text was updated successfully, but these errors were encountered: