Spring boot 有没有办法在SpringBoot应用程序配置中使用SpringCloud{cipher}?
我有一个使用SpringCloud配置的SpringBoot应用程序,但我想在SpringBootApps bootstrap.yml文件中加密SpringCloud配置密码。有办法做到这一点吗?下面是一个例子 Spring Boot应用程序bootstrap.ymlSpring boot 有没有办法在SpringBoot应用程序配置中使用SpringCloud{cipher}?,spring-boot,spring-cloud,Spring Boot,Spring Cloud,我有一个使用SpringCloud配置的SpringBoot应用程序,但我想在SpringBootApps bootstrap.yml文件中加密SpringCloud配置密码。有办法做到这一点吗?下面是一个例子 Spring Boot应用程序bootstrap.yml spring: cloud: config: uri: http://locahost:8888 username: user password: '{cipher}encrypte
spring:
cloud:
config:
uri: http://locahost:8888
username: user
password: '{cipher}encryptedpassword'
配置客户端中支持加密属性(如中所述)。显然,如果您这样做,您必须在运行时提供一个密钥来解密属性,因此实际上我并不总是看到好处(我认为配置文件有点像一个具有特殊格式的密钥库,因此您只有一个密钥需要保护,而不是多个)。示例(application.yml): 和键(在bootstrap.yml中):
我发现了一些与此相关的事情 如果使用bootstrap.yml(或application.yml),密码文本的格式必须包含在单引号内:
security.user.password: '{cipher}56e611ce4a99ffd99908d2c9aa1461d831722812e4370a5b6900b7ea680ae914'
如果使用bootstrap.properties(或application.properties),密码文本的格式不得包含在内:
security.user.password= {cipher}56e611ce4a99ffd99908d2c9aa1461d831722812e4370a5b6900b7ea680ae914
[reference docs][1]显示的是没有引号的yml,这是我从未使用过的。SnakeYaml始终报告错误:
"expected <block end>, but found Scalar"
“应为标量,但找到标量”
您可以使用Spring CLI对机密进行加密Spring encrypt password——密钥“SECRET\u key”
谢谢你,戴夫。我不确定我昨天做错了什么,但我没能让它工作。我已将ENCRYPT_KEY设置为OS环境变量。我今天又试了一次,它仍然有效。对于任何有同样问题的人,Intellij(可能还有其他IDE)都会在启动时加载环境变量。。。因此,要加载新的/更改的环境变量,需要关闭并重新启动Intellij..properties files uses=,而不是“:”
security.user.password= {cipher}56e611ce4a99ffd99908d2c9aa1461d831722812e4370a5b6900b7ea680ae914
"expected <block end>, but found Scalar"