How to use Python's OpenSSL lib in order to create RSA pairs and CRS from them?

197 views Asked by At

I just had started my studies about SSL recently and I need to create a RSA key pairs, then use'em to create a CSR. It must be done in Python, due my projects needs.

I took a look around several libs and their documentations, as also websites, blogs and some books too, but everything I've found is or only at Linux (which help me to understand better about SSL) or not exacly what I'm looking for.

I also gonna need to validate certificate chains and learn about HTTP GET using HTTPS with certification, but I can take care of that later.

(I don't know, it looks basic stuff but I ain't figuring out anyways)

Any help will be welcome and I'm sorry if I wasn't clear enough.

1

There are 1 answers

0
R. Marinho On

Ok, the idea of using PKIutils lib made his effort. I could not installed in the beginning in order of some problems and issues with Python (2.7), but they are now solved.

This lib is really the thing I was looking for and is very simple once it does his job in a basic way with a proportional effort.

As we can see in its docs (http://python-pkiutils.readthedocs.io/en/latest/), we just need to call as the example:

key = pkiutils.create_rsa_key(1024, keyfile='') csr = pkiutils.create_csr (key, dn="/C=GB/ST=STATENAME/L=LOCAILITY/O=COMPANY/OU=DEPT/CN=www.example.com", csrfilename='')

This is just an example, of course, but it creates the RSA pair and the CSR anyways.

Solved my problem; maybe it can be useful for somebody else.