2 # SPDX-License-Identifier: LGPL-2.1-or-later
5 import cryptography.x509
11 sys.exit('USAGE: update-test-database.py ca.pem output_header.h')
13 with open(in_path, 'rb') as in_file:
14 cert_data = in_file.read()
16 cert = cryptography.x509.load_pem_x509_certificate(cert_data)
17 subject_data = cert.subject.public_bytes()
18 hex_subject = ''.join('\\x%02X' % b for b in subject_data)
20 header = '''/* This file is generated from update-test-database.py */
22 #define ISSUER_DATA "{}"
23 '''.format(hex_subject)
25 with open(out_path, 'w') as out_file:
26 out_file.write(header)