mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-29 12:22:52 +03:00
CTAP: Handle broken HID connection
This commit is contained in:
parent
db147cdbc3
commit
e453bda217
@ -45,6 +45,7 @@ from ykman.pcsc import list_devices, YK_READER_NAME
|
|||||||
from smartcard.Exceptions import SmartcardException, NoCardException
|
from smartcard.Exceptions import SmartcardException, NoCardException
|
||||||
from smartcard.pcsc.PCSCExceptions import EstablishContextException
|
from smartcard.pcsc.PCSCExceptions import EstablishContextException
|
||||||
from smartcard.CardMonitoring import CardObserver, CardMonitor
|
from smartcard.CardMonitoring import CardObserver, CardMonitor
|
||||||
|
from fido2.ctap import CtapError
|
||||||
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePublicKey
|
from cryptography.hazmat.primitives.asymmetric.ec import EllipticCurvePublicKey
|
||||||
from hashlib import sha256
|
from hashlib import sha256
|
||||||
from dataclasses import asdict
|
from dataclasses import asdict
|
||||||
@ -349,6 +350,11 @@ class UsbDeviceNode(AbstractDeviceNode):
|
|||||||
except (ValueError, OSError) as e:
|
except (ValueError, OSError) as e:
|
||||||
logger.warning("Error opening connection", exc_info=True)
|
logger.warning("Error opening connection", exc_info=True)
|
||||||
raise ConnectionException(self._device.fingerprint, "fido", e)
|
raise ConnectionException(self._device.fingerprint, "fido", e)
|
||||||
|
except Exception as e: # TODO: Replace with ConnectionError once added
|
||||||
|
if "Wrong" in str(e):
|
||||||
|
logger.warning("Error opening connection", exc_info=True)
|
||||||
|
raise ConnectionException(self._device.fingerprint, "fido", e)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
class _ReaderObserver(CardObserver):
|
class _ReaderObserver(CardObserver):
|
||||||
@ -445,6 +451,14 @@ class ConnectionNode(RpcNode):
|
|||||||
if e.sw == SW.INVALID_INSTRUCTION:
|
if e.sw == SW.INVALID_INSTRUCTION:
|
||||||
raise ChildResetException(f"SW: {e.sw}")
|
raise ChildResetException(f"SW: {e.sw}")
|
||||||
raise e
|
raise e
|
||||||
|
except CtapError as e:
|
||||||
|
if e.code == CtapError.ERR.CHANNEL_BUSY:
|
||||||
|
raise ChildResetException(str(e))
|
||||||
|
raise
|
||||||
|
except Exception as e: # TODO: Replace with ConnectionError once added
|
||||||
|
if "Wrong" in str(e):
|
||||||
|
raise ChildResetException(str(e))
|
||||||
|
raise
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def capabilities(self):
|
def capabilities(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user