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 认证(只校验有效期)

相关推荐
feifeigo1231 小时前
升级到MySQL 8.4,MySQL启动报错:io_setup() failed with EAGAIN
数据库·mysql·adb
Albert Edison1 小时前
【最新版】IntelliJ IDEA 2025 创建 SpringBoot 项目
java·spring boot·intellij-idea
火龙谷2 小时前
【nosql】有哪些非关系型数据库?
数据库·nosql
Piper蛋窝2 小时前
深入 Go 语言垃圾回收:从原理到内建类型 Slice、Map 的陷阱以及为何需要 strings.Builder
后端·go
焱焱枫3 小时前
Oracle获取执行计划之10046 技术详解
数据库·oracle
qq_392397125 小时前
Redis常用操作
数据库·redis·wpf
六毛的毛5 小时前
Springboot开发常见注解一览
java·spring boot·后端
AntBlack5 小时前
拖了五个月 ,不当韭菜体验版算是正式发布了
前端·后端·python
31535669135 小时前
一个简单的脚本,让pdf开启夜间模式
前端·后端
uzong5 小时前
curl案例讲解
后端