简体   繁体   English

如何在Python3中生成SSL证书

[英]How to generate an SSL certificate in Python3

I need to generate self-signed certs for using HTTPS on a single-user web server. 我需要生成用于在单用户Web服务器上使用HTTPS的自签名证书。 It's important that the user is able to set the certificate up however they like. 用户能够根据自己的喜好设置证书,这一点很重要。 They need to be able to set the Common Name and so on. 他们需要能够设置通用名称,依此类推。

In an pure Python3 environment, how do you generate a self-signed certificate? 在纯Python3环境中,如何生成自签名证书?

To create self-signed certificate you could use openssl as it is available on all major OSes. 要创建自签名证书,可以使用openssl,因为它在所有主要操作系统上均可用。

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

Try the above code in python and see if it works. 在python中尝试上面的代码,看看是否可行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM