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
diff --git a/src/python_testing/TC_DA_1_2.py b/src/python_testing/TC_DA_1_2.py
index 9bf08fe..5c0b6db 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 @@
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