aboutsummaryrefslogtreecommitdiff
path: root/scripts/gski.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gski.py')
-rw-r--r--scripts/gski.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/scripts/gski.py b/scripts/gski.py
index f7e6dbf6..6d1e34c3 100644
--- a/scripts/gski.py
+++ b/scripts/gski.py
@@ -1,6 +1,6 @@
# $Id$
-import POW, POW.pkix, base64, getopt, sys
+import rpki.x509, POW.pkix, base64, getopt, sys
opts, args = getopt.getopt(sys.argv[1:], "", ["pem", "der"])
@@ -11,12 +11,9 @@ for o, a in opts:
if o == "--der": use_pem = False
for file in args:
- f = open(file, "r")
- der = f.read()
- f.close()
if use_pem:
- der = POW.pemRead(POW.X509_CERTIFICATE, der).derWrite()
- cert = POW.pkix.Certificate()
- cert.fromString(der)
- ski = base64.b64encode([x for x in cert.getExtensions() if x[0] == (2, 5, 29, 14)][0][2]).replace("+", "-").replace("/", "_")
+ cert = rpki.x509.X509(PEM_file=file)
+ else:
+ cert = rpki.x509.X509(DER_file=file)
+ ski = base64.b64encode([x for x in cert.get_POWpkix().getExtensions() if x[0] == (2, 5, 29, 14)][0][2]).replace("+", "-").replace("/", "_")
print ski, file