openssl下載:https://slproweb.com/products/Win32OpenSSL.html,建議下載1.1.1版本,不然生成的p12證書Mac電腦安裝不了
//生成自定義.key 私鑰
openssl genrsa -out xxx.key 2048
//生成RSA公鑰 openssl rsa -in xxx.key -pubout -out rsa_public_key.pem
//輸出證書注冊文件
openssl req -new -sha256 -key xxx.key -out xxx.csr -subj "/emailAddress=xxxxxxxx@163.com"
//生成證書 openssl x509 -req -days 365 -in xxx.csr -signkey xxx.key -out cert.crt
//生成pem文件
openssl x509 -in xxxx.cer -inform DER -out xxxx.pem -outform PEM
//生成p12證書,并設(shè)置證書密碼
//如果用mac電腦生成,為了兼容舊版本,可以加-legacy參數(shù)
//openssl pkcs12 -legacy -export -inkey xxx.key -in xxxx.pem -out xxxx.p12 -password pass:123456
openssl pkcs12 -export -inkey xxx.key -in xxxx.pem -out xxxx.p12 -password pass:123456
//驗證p12證書
//openssl pkcs12 -legacy -in ios_development.p12 -info
openssl pkcs12 -in ios_development.p12 -info
//查看P12證書有效期
openssl pkcs12 -in ios_development.p12 -clcerts -nodes | openssl x509 -noout -enddate
//獲取證書的序列號和subject
openssl x509 -in ios_development.cer -noout -serial -subject
//RSA由私鑰文件獲取公鑰文件
openssl rsa -in xxx.key -pubout -out xxx_pub.key
參考資料:
https://www.yii666.com/blog/394250.html
https://www.cnblogs.com/leeke98/p/17240987.html
https://www.bilibili.com/read/cv14924390