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证书,并设置证书密码
//如果用mac电脑生成,为了兼容旧版本,可以加-legacy参数
//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