Spring Cloud Config-属性解密在客户端不起作用

Ind*_*nde 1 java spring-boot spring-cloud spring-cloud-config

我有一个用于配置客户端和配置服务器的基本设置(与此处的教程完全相同-https : //spring.io/guides/gs/centralized-configuration/

我的问题是我可以解密服务器端的属性并将其作为纯文本发送,但是不能解密客户端而不是服务器端的属性。我正在使用对称加密,并且已经多次阅读了文档,但是无法在客户端工作时得到解密。

我在服务器端添加了以下属性,因此它不会在服务器端解密属性-

       spring.cloud.config.server.encrypt.enabled=false
Run Code Online (Sandbox Code Playgroud)

我有一个application.yml文件,该文件具有加密的值-

       name: '{cipher}hdshdghsgdhjsgdhsgdyassudyadssd2313wdw2e'
Run Code Online (Sandbox Code Playgroud)

我尝试将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>
Run Code Online (Sandbox Code Playgroud)

..............

在配置服务器中,我添加了属性-

           spring.cloud.config.server.encrypt.enabled=false
Run Code Online (Sandbox Code Playgroud)

在配置客户端上,我在application.properties和bootstrap.properties中都添加了crypto.key。

           encrypt.key=abcd
Run Code Online (Sandbox Code Playgroud)

Ind*_*nde 5

因此,这就是解决问题的方法。我添加了以下属性-

          spring.cloud.config.server.encrypt.enabled=false
Run Code Online (Sandbox Code Playgroud)

在配置服务器端的application.properties/yaml中。错了 它需要

放在bootstrap.properties/yaml中,而不是application.properties/yaml中。

可以将其明确添加到文档中吗?

我确实在文档中看到了上面提到的属性,但是没有提到应该添加的位置。

https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html