OPENSSL申请证书
1.windows下载openssl
2.安装后,进入 D:\OpenSSL-Win64\bin,cmd进入该目录,执行openssl
3.此时会报一个错,缺少openssl.cnf,把它拷贝到C:\Program Files\Common Files\SSL
4. 在openssl下依次执行:
第 1 步: 为私有密钥验证证书生成密钥对
openssl genrsa -out verificationCert.key 2048
第 2 步: 复制此注册代码
abcdefghijklmnxxxxxxxxxxxxxxxxxxxxxxxxxx
第 3 步: 使用此注册代码创建 CSR
openssl req -new -key verificationCert.key -out verificationCert.csr
将此注册代码放在公用名字段中
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []: abcdefghijklmnxxxxxxxxxxxxxxxxxxxxxxxxxx
Email Address []:
第 4 步: 使用由 CA 私有密钥签名的 CSR 创建私有密钥验证证书
openssl x509 -req -in verificationCert.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out verificationCert.crt -days 500 -sha256
注意,生成的crt与csr均在bin目录下,-CA rootCA.pem -CAkey rootCA.key需要先生成根证书,生成指令如下:
openssl genrsa -out rootCA.key 2048
openssl genrsa -des3 -out rootCA.key 2048 //如不需要加密,可去掉 -des3
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem
生成后的rootCA的pem与key均在bin目录下
执行完之后如下:
image.png成功后,bin目录出现 verificationCert.crt
参考:
Creating Your Own SSL Certificate Authority (and Dumping Self Signed Certs)
https://datacenteroverlords.com/2012/03/01/creating-your-own-ssl-certificate-authority/