1.下载OpenSSL软件
网站地址:Win32/Win64 OpenSSL Installer for Windows - Shining Light Productions
安装: 一直点击下一步就可以了
2.设置环境变量
在开始菜单右键「此电脑」→「属性」→「高级系统设置」→「环境变量」
在Path 中添加一个: xxxx\OpenSSL-Win64\bin → 「保存变量」
在通过该命令验证:openssl version
3.打开安装OpenSSL的位置
进入→ xxxx\OpenSSL-Win64\bin → 查看是否有"openssl.cnf"文件,如果没有就创建
openssl.cnf :
[ req ]
default_bits = 2048
default_keyfile = key.pem
distinguished_name = req_distinguished_name
x509_extensions = v3_ca
prompt = yes
[ req_distinguished_name ]
C = CN
ST = Beijing
L = Beijing
O = MyCompany
OU = MyUnit
CN = localhost
[ v3_ca ]
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer
basicConstraints = CA:true
4.创建cert.pem 和 key.pem
4.1 修改自己的安装位置,运行下面命令
openssl req -new -x509 -days 365 -nodes ^
-config "D:\app\OpenSSL-Win64\OpenSSL-Win64\bin\openssl.cnf" ^ ----修改为自己的安装位置
-out cert.pem -keyout key.pem
4.2 按照提示,确认信息。
4.3 查看证书信息
openssl x509 -in cert.pem -text -noout
cert.pem
:证书文件
key.pem
:私钥文件