Indraneel Bende
Indraneel Bende

Reputation: 3486

Spring Cloud Config- Decryption of properties is not working on Client Side

I have a basic setup for a config client and config server( exactly as in the tutorial here- https://spring.io/guides/gs/centralized-configuration/

My issue is I can decrypt properties on the server side and send them over as plain text but cannot decrypt properties on the client side rather than the server side. I am using symmetric encryption, and have gone through the documentation several times but am unable to get decryption on client side working.

I have added the following property on the server side, so it does not decrypt properties on the server side-

       spring.cloud.config.server.encrypt.enabled=false

I have an application.yml file which has a encrypted value-

       name: '{cipher}hdshdghsgdhjsgdhsgdyassudyadssd2313wdw2e'

I have tried adding ENCRYPT_KEY/encrypt.key as an environment variable, system property on the client side. Also, have tried adding the same in application.properties and bootstrap.properties but the client is not able to decrypt.

Thank you in advance.

Config Client 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>

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

In the config Server i have added the property-

           spring.cloud.config.server.encrypt.enabled=false

On the config Client side, I have added encrypt.key in both application.properties and bootstrap.properties.

           encrypt.key=abcd

Upvotes: 1

Views: 3967

Answers (1)

Indraneel Bende
Indraneel Bende

Reputation: 3486

So, this is what solved it. I had added the following property-

          spring.cloud.config.server.encrypt.enabled=false

in application.properties/yaml on the config server side. This was wrong. It needs

to be inside bootstrap.properties/yaml instead of application.properties/yaml.

Can this be added to the documentation explicitly?

I do see the mention of the property above in the documentation but not of the location it should be added in.

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

Upvotes: 8

Related Questions