From e7ff441fa11ec17d3679186b551d6a408f091c87 Mon Sep 17 00:00:00 2001 From: C Freeman Date: Tue, 15 Oct 2024 09:36:16 -0400 Subject: [PATCH] TC-DA-1.2: Better error messages (#35916) * TC-DA-1.2: Better error messages Test: Added a bad der file in the cd-certs dir, saw failure on ToT, no failure with this fix. * whoops, forgot to add this change * linter --- src/python_testing/TC_DA_1_2.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_DA_1_2.py b/src/python_testing/TC_DA_1_2.py index 9bf08fe72afdf0..5c0b6dbf154d7c 100644 --- a/src/python_testing/TC_DA_1_2.py +++ b/src/python_testing/TC_DA_1_2.py @@ -35,6 +35,7 @@ # quiet: true # === END CI TEST ARGUMENTS === +import logging import os import random import re @@ -391,7 +392,12 @@ async def test_TC_DA_1_2(self): if '.der' not in filename: continue with open(os.path.join(cd_cert_dir, filename), 'rb') as f: - cert = x509.load_der_x509_certificate(f.read()) + logging.info(f'Parsing CD signing certificate file: {filename}') + try: + cert = x509.load_der_x509_certificate(f.read()) + except ValueError: + logging.info(f'File {filename} is not a valid certificate, skipping') + pass pub = cert.public_key() ski = x509.SubjectKeyIdentifier.from_public_key(pub).digest certs[ski] = pub