【发布时间】:2018-07-29 07:30:39
【问题描述】:
我有一个配置客户端和配置服务器的基本设置(与此处的教程完全相同-https://spring.io/guides/gs/centralized-configuration/
我的问题是我可以在服务器端解密属性并将它们作为纯文本发送,但不能在客户端而不是服务器端解密属性。我正在使用对称加密,并且已经多次阅读文档,但无法在客户端工作时解密。
我在服务器端添加了以下属性,所以它不会解密服务器端的属性-
spring.cloud.config.server.encrypt.enabled=false
我有一个具有加密值的 application.yml 文件-
name: '{cipher}hdshdghsgdhjsgdhsgdyassudyadssd2313wdw2e'
我尝试在客户端添加 ENCRYPT_KEY/encrypt.key 作为环境变量、系统属性。另外,尝试在 application.properties 和 bootstrap.properties 中添加相同的内容,但客户端无法解密。
提前谢谢你。
配置客户端 POM-
.......................
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
<version>1.4.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Edgware.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
.......
在配置服务器中我添加了属性-
spring.cloud.config.server.encrypt.enabled=false
在配置客户端,我在 application.properties 和 bootstrap.properties 中都添加了 encrypt.key。
encrypt.key=abcd
【问题讨论】:
-
你在客户端配置好密钥了吗?
-
重现问题的样本会有所帮助。
-
刚刚更新了我的帖子,为我的错误缩进道歉:)
-
你可以在不指定不应该需要的依赖项中的配置服务器版本的情况下尝试它。您也可以将代码放在 GitHub 上的存储库中吗?
-
你是说尤里卡服务器吗?上面的 pom 是一个配置客户端 pom。
标签: java spring-boot spring-cloud spring-cloud-config