-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and integrate signature validation. It's also optional now and wa…
…rns if packages are missing.
- Loading branch information
Hagen Fritsch
committed
Jan 15, 2022
1 parent
9a3a67f
commit d9e049f
Showing
3 changed files
with
175 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import csv | ||
import itertools | ||
import xml.etree.ElementTree as ET | ||
import requests | ||
|
||
def get_uic_certs(): | ||
certurl = 'https://railpublickey.uic.org/download.php' | ||
xmlpubkeys = requests.get(certurl).text | ||
|
||
root = ET.fromstring(xmlpubkeys) | ||
|
||
for child in root: | ||
issuer = int(child.find('issuerCode').text) | ||
xid = int(child.find('id').text) | ||
pubkey = child.find('publicKey').text | ||
pubkey = f'-----BEGIN CERTIFICATE-----\n{pubkey}\n-----END CERTIFICATE-----' | ||
yield (issuer, xid, pubkey) | ||
|
||
def get_db_certs(): | ||
base_url = 'https://sourceforge.net/p/dbuic2vdvbc/code/ci/master/tree/certs/production/' | ||
issuer = 80 | ||
for xid in [1,6,7,8]: | ||
pubkey = requests.get(f'{base_url}{issuer:04}{xid:05}.pem?format=raw').text | ||
yield (issuer, xid, pubkey) | ||
|
||
if __name__ == '__main__': | ||
with open('certs.csv', 'w') as certsfile: | ||
certwriter = csv.writer(certsfile, delimiter='\t') | ||
for issuer, xid, pubkey in itertools.chain( | ||
get_uic_certs(), | ||
get_db_certs()): | ||
certwriter.writerow((issuer, xid, pubkey)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters