Skip to content

Commit 4250593

Browse files
committed
handle missing leaf certificate
1 parent d76cda9 commit 4250593

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/fido_mds/helpers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ def load_raw_cert(cert: Union[bytes, str]) -> x509.Certificate:
3131

3232
def cert_chain_verified(cert_chain: List[Certificate], root_certs: List[Certificate]) -> bool:
3333
cert_verified = False
34-
cert_to_check = cert_chain[0] # first cert in chain is the one we want to verify
34+
try:
35+
cert_to_check = cert_chain[0] # first cert in chain is the one we want to verify
36+
except IndexError:
37+
logger.error('no certificate to validate in certificate chain')
38+
return cert_verified
39+
3540
# create store and add root cert
3641
for root_cert in root_certs:
3742
store = crypto.X509Store()

0 commit comments

Comments
 (0)