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

相关推荐
吃海鲜的骆驼10 分钟前
服务异步通讯与RabbitMQ
java·分布式·后端·rabbitmq
m0_7482336412 分钟前
RabbitMQ 进阶
android·前端·后端
羱滒14 分钟前
sql调优之数据库开发规范
java·数据库·数据库开发
程序员Android16 分钟前
MTK多帧拍照流程分析
数据库
不剪发的Tony老师18 分钟前
Apache Doris:一款高性能的实时数据仓库
数据库·数据仓库
m0_7482386321 分钟前
Spring Boot项目接收前端参数的11种方式
前端·spring boot·后端
桦说编程23 分钟前
【硬核总结】如何轻松实现只计算一次、惰性求值?良性竞争条件的广泛使用可能超过你的想象!String实际上是可变的?
后端·函数式编程
甜可儿29 分钟前
redis序列化设置
数据库·redis
GGBondlctrl34 分钟前
【SpringBoot】论坛项目中如何进行实现发布文章,以及更新对应数据库的数据更新
数据库·springboot项目·三层设计思想·文章发布项目
若云止水1 小时前
Ubuntu 下 nginx-1.24.0 源码分析 - ngx_init_cycle 函数 - 详解(4)
数据库·nginx·ubuntu