From fad423c25c91a8caf368349a7d717af6b1284ca9 Mon Sep 17 00:00:00 2001 From: Dain Nilsson Date: Fri, 30 Aug 2024 11:12:01 +0200 Subject: [PATCH] Don't fail on ykneo-openpgp < 1.0.2 --- yubikit/openpgp.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/yubikit/openpgp.py b/yubikit/openpgp.py index 864753bb..4e36ba32 100644 --- a/yubikit/openpgp.py +++ b/yubikit/openpgp.py @@ -1023,8 +1023,14 @@ def __init__( def _read_version(self) -> Version: logger.debug("Getting version number") - bcd = self.protocol.send_apdu(0, INS.GET_VERSION, 0, 0) - return Version(*(_bcd(x) for x in bcd)) + try: + bcd = self.protocol.send_apdu(0, INS.GET_VERSION, 0, 0) + return Version(*(_bcd(x) for x in bcd)) + except ApduError as e: + # Pre 1.0.2 versions don't support reading the version + if e.sw == SW.CONDITIONS_NOT_SATISFIED: + return Version(1, 0, 0) + raise @property def aid(self) -> OpenPgpAid: