uniapp使用生成自有证书
1.安装JRE环境
可从Oracle官方下载jre安装包:https://www.oracle.com/technetwork/java/javase/downloads/index.html
安装完成后将bin目录(我的为C:\Program Files\Java\jdk-17.0.1\bin)加入系统环境变量
2.使用keytool -genkey命令生成证书
注意:利用uniapp指导手册的方法云打包会出现,证书文件不是有效地keystore文件,可以参考 https://www.jianshu.com/p/44781e2f7044
需要改进方法:
keytool -genkey -alias testalias -keyalg RSA -sigalg SHA1WithRSA -validity 20000 -keysize 1024 -keystore C:/keyStore/test.keystore -v
注意我的保存路径为
C:/keyStore/test.keystore
需要建一个C:/keyStore/文件夹,不然会找不到是路径
继续按提示输入相关消息
再执行命令更改秘钥库类型
keytool -importkeystore -srckeystore ./test.keystore -destkeystore ./test.keystore -deststoretype JKS
就可以使用新生成的证书进行云打包了
查看秘钥的方法
keytool -list -v -keystore test.keystore
再输入密码就可以查看秘钥了
因为jdk版本的原因,根据命令可能获取不到证书的md5信息(授权一键登录审核应用时会用到),更换jdk版本又会加重工作量,这里可以使用香蕉云编查看证书信息,如下:
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
2024年3月补充:
获取证书的md5信息
keytool -exportcert -keystore ./test.keystore | openssl dgst -md5
输入密码后可以获得md5信息
注意:如果报错
默认的Windows系统是不带openssl功能的,因此当需要生成密钥或证书时需要先安装openssl库;
查看公钥的方法
1.转成pem证书
keytool -export -alias testalias -file certificate.cer -keystore test.keystore
2.查看公钥
keytool -list -rfc --keystore ./test.keystore | openssl x509 -inform pem -pubkey
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------