TrueLicense 使用JDK自带的 keytool 工具生成公私钥证书库
假如我们设置公钥库密码为: public_password1234 ,私钥库密码为: private_password1234 ,则生成命令如下:
生成命令
keytool -genkeypair -keysize 1024 -validity 3650 -alias "privateKey" -keystore "privateKeys.keystore" -storepass "public_password1234" -keypass "private_password1234" -dname "CN=localhost, OU=localhost, O=localhost, L=SH, ST=SH, C=CN"
导出命令
keytool -exportcert -alias "privateKey" -keystore "privateKeys.keystore" -storepass "public_password1234" -file "certfile.cer"
导入命令
keytool -import -alias "publicCert" -file "certfile.cer" -keystore "publicCerts.keystore" -storepass "public_password1234"
复制代码
上述命令执行完成之后,会在当前路径下生成三个文件,分别是:privateKeys.keystore、publicCerts.keystore、certfile.cer。 其中文件certfile.cer不再需要可以删除,文件privateKeys.keystore用于当前的 ServerDemo 项目给客户生成license文件,而文件publicCerts.keystore则随应用代码部署到客户服务器,用户解密license文件并校验其许可信
spring boot 配置
#License相关配置
license:
#主题
subject: license_demo
#公钥别称
publicAlias: publicCert
#访问公钥的密码
storePass: public_password1234
#license位置 如果不是绝对地址 则会找项目资源路径
licensePath: license/license.lic
#公钥位置 如果不是绝对地址 则会找项目资源路径
publicKeysStorePath: license/publicCerts.keystore
######生成许可证书信息 *此信息应当绝对保密 正式项目应该分离单独存放用于生成许证书* 你可以屏蔽############私钥库别名
privateAlias: privateKey
#私钥库密码
keyPass: private_password1234
#私钥库路径
privateKeysStorePath: license/privateKeys.keystore
########################License认证相关#####################