Skip to content

Commit

Permalink
PIV: Improve handling of malformed certificate data object.
Browse files Browse the repository at this point in the history
  • Loading branch information
dainnilsson committed Nov 24, 2023
1 parent 6734213 commit 349852a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions yubikit/piv.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,11 +808,11 @@ def get_certificate(self, slot: SLOT) -> x509.Certificate:
logger.debug(f"Reading certificate in slot {slot}")
try:
data = Tlv.parse_dict(self.get_object(OBJECT_ID.from_slot(slot)))
except ValueError:
cert_data = data[TAG_CERTIFICATE]
cert_info = data[TAG_CERT_INFO][0] if TAG_CERT_INFO in data else 0
except (ValueError, KeyError):
raise BadResponseError("Malformed certificate data object")

cert_data = data[TAG_CERTIFICATE]
cert_info = data[TAG_CERT_INFO][0] if TAG_CERT_INFO in data else 0
if cert_info == 1:
logger.debug("Certificate is compressed, decompressing...")
# Compressed certificate
Expand Down

0 comments on commit 349852a

Please sign in to comment.