java - 无法使用非对称加密解密 Spring Cloud 配置中的配置属性
问题描述
我正在尝试从配置服务器加载解密的配置属性,但失败并出现以下错误:
2018-08-07 09:58:26.534 WARN 20400 --- [nio-8888-exec-3] osccseCipherEnvironmentEncryptor:无法解密密钥:密码(java.lang.IllegalStateException 类:无法从存储区加载密钥:类路径资源 [服务器.jks])
当 server.jks 放置在类路径中时会发生此错误。但是当放置在 C:\drive 位置时,它工作正常。
我的配置服务器 bootstrap.yml:
encrypt:
key-store:
# location: file:///C:/keystore/server.jks #using asymmetric encryption
location: classpath:/server.jks #using asymmetric encryption
password: springcloudconfig
alias: testconfigkey
secret: springcloudconfig
# key: springcloudconfig #using symmetric encryption
关于我缺少什么的任何想法?非常感谢您的帮助!Spring Boot:2.0.3 JCE 安装 jre/lib 位置
解决方案
我刚刚注意到配置服务器项目中不存在 server.jks 文件。放置文件后,它会正确解密内容。
源代码在 Github 中可用:
推荐阅读
- python - 画布中分层图像的事件处理
- asp.net-core - preLaunchTask 未在启动配置中的 ${command:pickRemoteProcess} 之前执行
- c# - 数据透视表聚合的 Excel 性能
- javascript - 如何调用rest api并将结果提供给后续的promise调用
- c++ - C++ char Arrays 与数组进行比较并分配单个值;
- java - 将项目添加到收藏夹数据库时更改图标颜色
- javascript - 如何在这个 JavaScript 中放置一个循环?
- r - RStudio 的 Anaconda Navigator 安装问题
- swift - 如何将应用程序的方向锁定为 iPhone *only* 的纵向?
- python - 如何根据关键字将字符串拆分为新的数据框行