Spring Boot实现License生成和校验

Spring Boot实现License生成和校验

证书准备

shell 复制代码
# 1. 生成私钥库
# validity:私钥的有效期(天)
# alias:私钥别称
# keystore:私钥库文件名称(生成在当前目录)
# storepass:私钥库密码(获取 keystore 信息所需的密码,密钥库口令)
# keypass:别名条目的密码(密钥口令)
# 执行该命令会生成一个privateKeys.keystore的文件
keytool -genkeypair -keysize 1024 -validity 3650 -alias "privateKey" -keystore "privateKeys.keystore" -storepass "pubwd123456" -keypass "priwd123456" -dname "CN=localhost, OU=localhost, O=localhost, L=SH, ST=SH, C=CN"

# 2. 把私钥库内的公钥导出到一个文件当中
# alias:私钥别称
# keystore:私钥库的名称(在当前目录查找)
# storepass:私钥库的密码
# file:证书名称
# 执行该命令会生成一个certfile.cer文件
keytool -exportcert -alias "privateKey" -keystore "privateKeys.keystore" -storepass "pubwd123456" -file "certfile.cer"

# 3.再把这个证书文件导入到公钥库,certfile.cer 没用了可以删掉了
# alias:公钥名称
# file:证书名称
# keystore:公钥文件名称
# storepass:公钥库密码
# 执行该命令会生成一个publicCerts.keystore文件的公钥库
keytool -import -alias "publicCert" -file "certfile.cer" -keystore "publicCerts.keystore" -storepass "pubwd123456"

# 查看
keytool -list -v -keystore privateKeys.keystore -storepass "pubwd123456"

# 删除
keytool -delete -alias privateKey -keystore "privateKeys.keystore" -storepass "pubwd123456"

查看密钥

执行删除命令后再次查看密钥

参考:

springboot实现License证书的授权和许可到期验证
Spring Boot实现License生成和校验
SpringBoot实现 License 认证(只校验有效期)

相关推荐
MaxHua38 分钟前
以 AI 之力重塑 Java 研发,解锁高效开发新范式
后端
Determined_man39 分钟前
多了这个@ResponseBody和没加有什么区别?
后端
八苦42 分钟前
VKProxy新增一些功能
后端
码农小站43 分钟前
ClickHouse 时间范围查询:精准筛选「本月数据」
数据库
上上迁1 小时前
分布式接口幂等性的演进和最佳实践,含springBoot 实现(Java版本)
java·spring boot·分布式
ApeAssistant1 小时前
Log4j2.xml配置总结,就这个标题就挺好
后端·apache log4j
WanderInk1 小时前
揭秘Java协变返回类型:让你的API少一点强转,多一点优雅
java·后端
心在飞扬1 小时前
AI开发应用 01-nodejs快速入门
后端·aigc·dnodejs
Ray661 小时前
「阅读笔记」elasticSearch 是什么?工作原理是怎么样的?
后端