diff options
-rwxr-xr-x | scripts/irbe-cli.py | 15 | ||||
-rw-r--r-- | scripts/rpki/left_right.py | 8 |
2 files changed, 18 insertions, 5 deletions
diff --git a/scripts/irbe-cli.py b/scripts/irbe-cli.py index 520b0d39..92582e89 100755 --- a/scripts/irbe-cli.py +++ b/scripts/irbe-cli.py @@ -4,7 +4,10 @@ Command line program to simulate behavior of the IR back-end. """ -import glob, rpki.left_right, rpki.relaxng, getopt, sys, lxml.etree +import glob, rpki.left_right, rpki.relaxng, getopt, sys, lxml.etree, POW, POW.pkix + +# Kludge around current test setup all being PEM rather than DER format +convert_from_pem = True class command(object): @@ -36,6 +39,16 @@ class command(object): def handle_peer_ta(self, arg): self.peer_ta = read_cert(arg) +def read_cert(filename): + f = open(filename, "r") + der = f.read() + f.close() + if convert_from_pem: + der = POW.pemRead(POW.X509_CERTIFICATE, der).derWrite() + cert = POW.pkix.Certificate() + cert.fromString(der) + return cert + class self(command, rpki.left_right.self_elt): elements = ("extension_preference",) diff --git a/scripts/rpki/left_right.py b/scripts/rpki/left_right.py index 3d03da21..7afae812 100644 --- a/scripts/rpki/left_right.py +++ b/scripts/rpki/left_right.py @@ -46,10 +46,10 @@ class base_elt(object): def __str__(self): lxml.etree.tostring(self.toXML(), pretty_print=True, encoding="us-ascii") -class biz_cert(POW.pkix.Certificate): - def __init__(self, text): - POW.pkix.Certificate.__init__(self) - self.fromString(base64.b64decode(text)) +def biz_cert(text): + cert = POW.pkix.Certificate() + cert.fromString(base64.b64decode(text)) + return cert class extension_preference_elt(base_elt): """ |