Skip to content

Commit

Permalink
verify: do not scan for hidraw devices, when device handle is known
Browse files Browse the repository at this point in the history
Connected: #122
  • Loading branch information
szszszsz committed Dec 10, 2021
1 parent bb8ccbc commit cc38a94
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pynitrokey/fido2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,22 @@ def reboot(
pass

def find_device(self, dev=None, solo_serial: str = None):
devices = []
if dev is None:
devices = list(CtapHidDevice.list_devices())
if solo_serial is not None:
if solo_serial.startswith("device="):
solo_serial = solo_serial.split("=")[1]
dev = open_device(solo_serial)
else:
devices = list(CtapHidDevice.list_devices())
devices = [
d for d in devices if d.descriptor.serial_number == solo_serial
]
if dev is None and len(devices) > 1:
else:
devices = list(CtapHidDevice.list_devices())
if len(devices) > 1:
raise pynitrokey.exceptions.NonUniqueDeviceError
if dev is None and len(devices) > 0:
if len(devices) > 0:
dev = devices[0]
if dev is None:
raise RuntimeError("No FIDO device found")
Expand Down

0 comments on commit cc38a94

Please sign in to comment.