java - 无法从 spring cloud 配置或环境变量中解密属性

标签 java spring-boot spring-cloud-config google-cloud-run google-cloud-kms

我正在尝试获取我的 KMS 库,found here , 解密我的 application.yml 中来自谷歌云配置服务器或环境变量的项目。

在玩弄过程中,我尝试了多种方案来让它发挥作用。理想情况下,我希望能够执行以下操作:

username: '{cipher}${db_username} 其中 ${db_username} 是我从谷歌云配置中读取的属性或环境变量。

到目前为止我已经尝试过:

username: ${username} -> 成功从云配置或环境变量中成功读取纯文本属性。 (无加密)

username: '{cipher}MyEncodedString' -> 成功 - 解码提供的内联字符串

❗️username: '{cipher}${username}' -> 我相信这是在尝试使用文字字符串 ${username}

❗️用户名:'{cipher}'${username} -> 无效格式/无法读取

因为当我将字符串内联时我可以看到我的解码工作正常,所以我认为这不是解码器的问题。

我可能也很笨,这不是我想做的场景,但我将这些存储在配置区域并让应用程序/配置文件提取并解密它似乎是合乎逻辑的需要。

如果它有所作为,而目前我觉得还没有,我正尝试在 Google Cloud Run + Java + Jib 上完成所有这些工作

最佳答案

您可以尝试使用属性文件吗?属性文件不需要 {cipher} 的单引号。机会较少但可以工作。

关于java - 无法从 spring cloud 配置或环境变量中解密属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57984457/

相关文章:

java - 无法使用 Java 中的 Cypher 查询在 Neo4J 数据库中的两个节点之间创建关系

java:抛出多个异常

Spring:ApplicationStartingEvent 不能转换为 ApplicationPreparedEvent for OptaPlanner Examination App

spring-boot - 将 Spring Boot 应用程序部署到 digital ocean

java - 如何在Spring Boot中使用JPA的entityManager.getReference?

java - 找不到 PropertySource : PKIX path building failed for spring cloud config URL

java - Apache httpclient 4.4 中的 Cookie 被忽略

java - 在 Spring Boot 应用程序中使用 MuleClient

java - 如何从 spring-config-server 应用程序使用 SSH 连接到 Bitbucket?

java - Spring Cloud Binder : mitigating cost of double bootstrap