使用JDK自带的keytool工具生成签名文件
作者:互联网
环境
- MacOS 10.14.6
- JDK1.8
生成私钥公钥
-
使用JDK自带的
keytool
工具生成签名keytool -genkeypair -keysize 1024 -validity 3650 -alias "zuiyuPrivateKey" -keypass "zuiyu_private_password_1234" -keystore "zuiyuPrivateKeys.keystore" -storepass "zuiyu_public_password_1234" -dname "CN=zuiyu,OU=zuiyu,O=zuiyu,L=BJ,ST=BJ,C=CN"
-
导出签名文件 zuiyuCertfile.cer
keytool -exportcert -alias "zuiyuPrivateKey" -keystore "zuiyuPrivateKeys.keystore" -storepass "zuiyu_public_password_1234" -file "zuiyuCertfile.cer"
-
导入签名文件
keytool -import -alias "zuiyuPublicCert" -file "zuiyuCertfile.cer" -keystore "zuiyuPublicCerts.keystore" -storepass "zuiyu_public_password_1234"
-
帮助命令(根据需要食用)
# 删除 keytool -delete -alias zuiyuPrivateKey -keystore "zuiyuPrivateKeys.keystore" -storepass "zuiyu_public_password_1234" # 查看 keytool -list -v -keystore zuiyuPrivateKeys.keystore -storepass "zuiyu_public_password_1234"
-
最后
上述命令执行完成之后,会在当前路径下生成三个文件,分别是:
zuiyuPrivateKeys.keystore
、zuiyuPublicCerts.keystore
、zuiyuCertfile.cer
。其中文件zuiyuCertfile.cer
不再需要可以删除,文件zuiyuPrivateKeys.keystore
用于当前的license-server
项目给客户生成license
文件,而文件zuiyuPublicCerts.keystore
则随应用代码部署到客户服务器,用户解密license文件并校验其许可信息。
license-server 项目参考
https://github.com/zuiyu-main/springboot-demo/tree/master/springboot-license
本文由mdnice多平台发布
标签:keystore,1234,password,zuiyu,keytool,JDK,签名文件,zuiyuPrivateKeys 来源: https://www.cnblogs.com/zuiyu/p/16596803.html