# springboot-license **Repository Path**: duhailiang/springboot-license ## Basic Information - **Project Name**: springboot-license - **Description**: license - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 4 - **Created**: 2023-11-02 - **Last Updated**: 2025-06-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # springboot-license #### 介绍 springboot-license #### 软件架构 license-common:授权基本公共包 license-spring-boot-starter:授权启动类,添加此依赖到客户端可自动配置授权方法 license-server:授权文件生成 license-client:客户端测试 #### 安装教程 1. 客户端引入license-spring-boot-starter则自动配置license验证,未通过验证无法进行登录,访问登录接口(包含"/login/"的url)会返回服务端机器码 2. 拿到机器码后启动license-server,要求输入机器码后,会在项目目录下生成四个文件 3. 将公钥"publicCerts.keystore"和授权文件"license.lic"拷贝到客户端项目目录下,重启启动客户端 注意:禁止透露私钥 #### keytool使用说明 1. 生成私钥库 ``` keytool -genkeypair -keysize 2048 -validity 3650 -alias "privateKey" -keystore "privateKeys.keystore" -storepass "publicpassword12345" -keypass "privatepassword12345" -dname "CN=localhost, OU=localhost, O=localhost, L=SH, ST=SH, C=CN" ``` 2. 将公钥导出至临时文件 ``` keytool -exportcert -alias "privateKey" -keystore "privateKeys.keystore" -storepass "publicpassword12345" -file "certfile.cer" ``` 3. 将文件导入到公钥库(新建) ``` keytool -import -alias "publicCert" -file "certfile.cer" -keystore "publicCerts.keystore" -storepass "publicpassword12345 -noprompt" ``` 4. 代码参数解释 ``` alias:条目别名 validity:证书有效期,单位:天 keystore:指定秘钥库的名称 storepass:指定秘钥库密码 keypass:指定别名对应密码(私钥密码) -noprompt: 不提示 -trustcacerts 信任来自 cacerts 的证书 -protected 通过受保护的机制的口令 -alias 要处理的条目的别名 -file 输入文件名 -keypass 密钥口令 -keystore 密钥库名称 -storepass 密钥库口令 -storetype 密钥库类型 -providername 提供方名称 -providerclass 提供方类名 -providerarg 提供方参数 -providerpath 提供方类路径 -v 详细输出 ``` 执行完以上三步之后,会在当前文件夹下生成privateKeys.keystore、publicCerts.keystore、certfile.cer三个文件,其中certfile.cer文件为临时文件可以删除,可以将privateKeys.keystore、publicCerts.keystore备份出来,方便使用。文件privateKeys.keystore用来为用户生成License文件,publicCerts.keystore岁应用工程部署到客户服务期,用其解密License文件并校验其许可信息。