醉鱼

V1

2022/08/17阅读:14主题:自定义主题1

使用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.keystorezuiyuPublicCerts.keystorezuiyuCertfile.cer。其中文件zuiyuCertfile.cer不再需要可以删除,文件zuiyuPrivateKeys.keystore用于当前的license-server项目给客户生成license文件,而文件zuiyuPublicCerts.keystore则随应用代码部署到客户服务器,用户解密license文件并校验其许可信息。

license-server 项目参考

https://github.com/zuiyu-main/springboot-demo/tree/master/springboot-license

分类:

后端

标签:

后端

作者介绍

醉鱼
V1