开发者

Create self signed SSL certificates in Python

I am trying to generate self signed SSL certificates using Python, so that it is platform independent. My target is the *.pem format.

I found this script that generates certificates, but no information how to self-sign them开发者_运维问答.


The script you've linked doesn't create self-signed certificate; it only creates a request.

To create self-signed certificate you could use openssl it is available on all major OSes.

$ openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095

If you'd like to do it using M2Crypto then take a look at X509TestCase.test_mkcert() method.


You could use the openssl method that J.F. Sebastian stated from within Python.

Import the OS lib and call the command like this:

os.system("openssl req -new -x509 -key privkey.pem -out cacert.pem -days 1095")

If it requires user interaction, it might work if you run it via subprocess pipe and allow for raw input to answer any prompts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜