1.签根证书:
- openssl genrsa -des3 -out rootca.key 1024
- openssl req -new -key rootca.key -out rootca.csr -config (证书绝对路径)\openssl.cnf
- openssl req -x509 -days 365 -key rootca.key -in rootca.csr -out rootca.crt -config (证书绝对路径)\openssl.cnf
Common Name 段 必填 否则无法 签名
2.签服务端证书 :
- openssl genrsa -des3 -out server.key 1024
- openssl rsa -in server.key -out server.key.unsecure
- openssl req -new -key server.key -out server.csr -config (证书绝对路径)\openssl.cnf
- openssl ca -in server.csr -out server.crt -cert rootca.crt -keyfile rootca.key -config (证书绝对路径)\openssl.cnf
> y
> y
3.签客户端证书:
- openssl genrsa -des3 -out client.key 1024
- openssl req -new -key client.key -out client.csr -config (证书绝对路径)\openssl.cnf
- openssl ca -in client.csr -out client.crt -cert rootca.crt -keyfile rootca.key -config (证书绝对路径)\openssl.cnf
>y
- openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.pfx
如果在签发证书时候提示demoCA找不到,则需要修改如下配置
修改:openssl.cnf 的 dir
在 openssl.exe 目录下
创建文件夹 demoCA
demoCA/newcerts
demoCA/private
创建空文件 demoCA/index.txt
创建文件 demoCA/serial 以文本形式写入 01
现在我们所需的全部文件便生成了.
另:
client使用的文件有:rootca.crt,client.crt,client.key
server使用的文件有:rootca.crt,server.crt,server.key
Enter PEM pass phrase: 解决方案
openssl rsa -in server.key -out server.key.unsecure
生成不安全秘钥
相关链接:
openssl : warning can’t open config file 解决办法 ( 使用环境变量
)
set OPENSSL_CONF=E:\ApacheSoftwareFoundation\Apache2.2\conf\openssl.cnf
http://impradeep.com/warning-cant-open-config-file-copenssl-1-0-1esslopenssl-cnf/