aboutsummaryrefslogtreecommitdiff
path: root/scripts/rpki/pkcs10.py
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2007-09-19 20:42:31 +0000
committerRob Austein <sra@hactrn.net>2007-09-19 20:42:31 +0000
commitf02848f2d0ebcfe6ddbb695e8bc0bd8697c2e6d1 (patch)
tree93340fbf6763b142e635a24acc25a1e0e7867bf1 /scripts/rpki/pkcs10.py
parent3442f7565e7be5df7ea170e2baa742e317049b51 (diff)
Checkpoint
svn path=/docs/left-right-xml; revision=995
Diffstat (limited to 'scripts/rpki/pkcs10.py')
-rw-r--r--scripts/rpki/pkcs10.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/scripts/rpki/pkcs10.py b/scripts/rpki/pkcs10.py
new file mode 100644
index 00000000..4d6a024a
--- /dev/null
+++ b/scripts/rpki/pkcs10.py
@@ -0,0 +1,35 @@
+# $Id$
+
+import POW, rpki.x509, os, rpki.exceptions, binascii
+
+req_fmt = '''
+[ req ]
+distinguished_name = req_dn
+prompt = no
+
+[ req_dn ]
+CN = %s
+'''
+
+def make_request(keypair):
+
+ digest = POW.Digest(POW.SHA1_DIGEST)
+ digest.update(keypair.get_POW().derWrite(POW.RSA_PUBLIC_KEY))
+ commonName = "0x" + binascii.hexify(digest.digest())
+
+ try:
+ config_filename = "req.tmp.conf"
+ f = open(config_filename, "w")
+ f.write(req_fmt % commonName)
+ f.close()
+
+ i,o = os.popen2(["openssl", "req", "-config", config_filename, "-new", "-key", "/dev/stdin", "-outform", "DER"])
+ i.write(keypair.get_PEM())
+ i.close()
+ pkcs10 = o.read()
+ o.close()
+
+ finally:
+ os.unlink(config_filename)
+
+ return pkcs10