File: update-test-database.py

package info (click to toggle)
glib-networking 2.80.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,796 kB
  • sloc: ansic: 21,084; sh: 129; python: 51; makefile: 19
file content (26 lines) | stat: -rwxr-xr-x 674 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
# SPDX-License-Identifier: LGPL-2.1-or-later

import sys
import cryptography.x509

try:
    in_path = sys.argv[1]
    out_path = sys.argv[2]
except IndexError:
    sys.exit('USAGE: update-test-database.py ca.pem output_header.h')

with open(in_path, 'rb') as in_file:
    cert_data = in_file.read()

cert = cryptography.x509.load_pem_x509_certificate(cert_data)
subject_data = cert.subject.public_bytes()
hex_subject = ''.join('\\x%02X' % b for b in subject_data)

header = '''/* This file is generated from update-test-database.py */

#define ISSUER_DATA "{}"
'''.format(hex_subject)

with open(out_path, 'w') as out_file:
    out_file.write(header)