aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2008-05-08 06:33:32 +0000
committerRob Austein <sra@hactrn.net>2008-05-08 06:33:32 +0000
commit429df3509115bfce062d5d29a35982f683870a15 (patch)
tree15ef0c61c66e4b3f6977381130367ed0ed7bcbc8
parent2e00b1f36053cc5a49bc6ad245bcaf0b78871a70 (diff)
Add ability to extract cert
svn path=/rpkid/extract-key.py; revision=1751
-rw-r--r--rpkid/extract-key.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/rpkid/extract-key.py b/rpkid/extract-key.py
index 53c15774..ebbda2d5 100644
--- a/rpkid/extract-key.py
+++ b/rpkid/extract-key.py
@@ -23,6 +23,8 @@ it is occasionally useful to be able to extract the private key from
MySQL. This script is just a convenience, it doesn't enable anything
that couldn't be done via the mysql command line tool.
+While we're at this we also extract the corresponding certificate.
+
Usage: python extract-key.py [ { -s | --self } self_id ]
[ { -b | --bsc } bsc_id ]
[ { -u | --user } mysql_user_id ]
@@ -71,10 +73,12 @@ if argv:
cur = MySQLdb.connect(user = user, db = db, passwd = passwd).cursor()
-cur.execute("SELECT private_key_id FROM bsc WHERE self_id = %s AND bsc_id = %s",
+cur.execute("SELECT private_key_id, signing_cert FROM bsc WHERE self_id = %s AND bsc_id = %s",
(self_id, bsc_id))
-key = rpki.x509.RSA(DER = cur.fetchone()[0])
+key, cer = cur.fetchone()
-print key.get_PEM()
+print rpki.x509.RSA(DER = key).get_PEM()
+if cer:
+ print rpki.x509.X509(DER = cer).get_PEM()