python openssl x509 CA

Marcin Jurczuk mjurczuk at gmail.com
Fri Oct 31 06:10:53 EDT 2008


Hello,
I'm fighting with Certificate Authority functionality with python
I stuck on following problem: How to sign CSR using CA key and write
resulted certificate.

You can do it using following openssl cmd:
openssl ca -cert CA/cert.pem -keyfile CA/private/cakey.pem -policy
policy_anything  -out user_cert.pem -infiles userreq.pem

My try was:
import OpenSSL.crypto as pki
#load CA key:
ca_key=pki.load_privatekey(pki.FILETYPE_PEM,open('CA/private/
cakey.pem').read(),'haselko')
#load user's csr:
csr=pki.load_certificate_request(pki.FILETYPE_PEM,open('userreq.pem').read())
# sign csr
csr.sign(ca_key,'sha1')
I don't get any erorrs however I dont' see any way to write or get
result from such operation
csr exports following methods:
csr.add_extensions  csr.get_pubkey      csr.get_subject
csr.set_pubkey      csr.sign            csr.verify

I want to create pure python implementation without use of openssl
wrapped with python code.

Regards,



More information about the Python-list mailing list