Openssl 创建证书
创建根证书CA
生成根证书的私钥
1
2
3
4openssl genrsa -out ca.key 2048
#genrsa --产生rsa密钥命令
#-out ---输出路径
#2048 --密钥的长度位数生成自签证书,即根证书CA
1
2
3
4
5openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
#new:表示生成一个新证书签署请求
#x509:专用于CA生成自签证书,如果不是自签证书则不需要此项
#key:用到的私钥文件
#days:证书的有效期限,单位是day(天)
颁发证书
生成私钥
1
openssl genrsa -out yourname.key 2048
生成证书签署请求
1
2
3openssl req -new -days 3650 -key yourname.key -out yourname.csr
##subject=/C=CN/ST=SH/L=SH/O=Boqii/OU=IT/CN=yourname/emailAddress=***@***.com#在根证书上,颁发证书
1
openssl x509 -req -in yourname.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out yourname.crt
格式转换
格式转换为pfx格式的私钥
1
openssl pkcs12 -export -out yourname.pfx -inkey yourname.key -in yourname.crt
格式转换为cer格式的公钥
1
openssl x509 -inform pem -in yourname.crt -outform der -out yourname.cer