diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-02-12 14:50:29 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-02-12 14:50:29 +0100 |
| commit | 0a3f6ea5f3983a5859206bab48812e1bd89b9c28 (patch) | |
| tree | 5737449c735ea7f5aad075d476f2a55ff9db208b /hacks | |
| parent | 9821a1172b0d6c5a809b822b255c03a76c624932 (diff) | |
Add get_certs_from_cpl.
Diffstat (limited to 'hacks')
| -rwxr-xr-x | hacks/get_certs_from_cpl | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/hacks/get_certs_from_cpl b/hacks/get_certs_from_cpl new file mode 100755 index 000000000..0b51b1243 --- /dev/null +++ b/hacks/get_certs_from_cpl @@ -0,0 +1,36 @@ +#!/usr/bin/python3 + +import os +import sys + +import bs4 + +with open(sys.argv[1]) as file: + xml = file.read() + +soup = bs4.BeautifulSoup(xml, 'xml') +signature = soup.CompositionPlaylist.Signature +if not signature: + print("Unsigned CPL") + sys.exit(0) + +number_of_certs = len(signature.KeyInfo.findAll('X509Certificate')) + +n = 0 +for data in signature.KeyInfo.findAll('X509Certificate'): + if n == 0: + name = 'leaf' + elif n == number_of_certs - 1: + name = 'root' + else: + name = f'inter_{number_of_certs - n - 1}' + + with open(f"{name}.pem", "w") as out: + print("-----BEGIN CERTIFICATE-----", file=out) + print(data.text, file=out) + print("-----END CERTIFICATE-----", file=out) + os.system(f"openssl x509 -text -in {name}.pem > {name}.dump") + os.system(f"openssl asn1parse < {name}.pem > {name}.asn1") + n += 1 + + |
