diff options
Diffstat (limited to 'potpourri')
-rwxr-xr-x | potpourri/rrdp-fetch-from-tal | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/potpourri/rrdp-fetch-from-tal b/potpourri/rrdp-fetch-from-tal index db4c0270..0a97955e 100755 --- a/potpourri/rrdp-fetch-from-tal +++ b/potpourri/rrdp-fetch-from-tal @@ -58,6 +58,7 @@ class main(object): if url is None: sys.exit("Couldn't get RRDP URI from trust anchor") self.rrdp_fetch(url) + self.write_ta() def rrdp_fetch(self, url): if url in self.urls: @@ -135,7 +136,7 @@ class main(object): def del_obj(self, uri, hash): fn = self.uri_to_filename(uri) with open(fn, "rb") as f: - if hash != rpki.x509.sha256(f.read()).encode("hex"): + if hash.lower() != rpki.x509.sha256(f.read()).encode("hex"): raise RuntimeError("Hash mismatch for URI %s" % uri) os.unlink(fn) dn = os.path.dirname(fn) @@ -149,7 +150,7 @@ class main(object): def xml_fetch(self, elt): url = elt.get("uri") - hash = elt.get("hash") + hash = elt.get("hash").lower() print "Fetching", url text = urllib2.urlopen(url).read() h = rpki.x509.sha256(text).encode("hex") @@ -190,5 +191,13 @@ class main(object): self.add_obj(elt.get("uri"), elt.text.decode("base64")) self.set_serial(new_serial) + def write_ta(self): + der = self.ta.get_DER() + fn = rpki.x509.sha256(der).encode("hex") + ".cer" + if not os.path.exists(fn): + print "Writing", fn + with open(fn, "wb") as f: + f.write(der) + if __name__ == "__main__": main() |