Search code examples
javaspring-bootencryptionspring-cloud-config

Unable to decrypt config property in Spring Cloud config using asymmetric encryption


I am trying to load the decrypted config property from config server but failing with below error:

2018-08-07 09:58:26.534 WARN 20400 --- [nio-8888-exec-3] o.s.c.c.s.e.CipherEnvironmentEncryptor : Cannot decrypt key: password (class java.lang.IllegalStateException: Cannot load keys from store: class path resource [server.jks])

This error happens when server.jks is placed in the classpath. But when placed in C:\drive location it works fine.

my config server bootstrap.yml:

encrypt:
  key-store:
   # location: file:///C:/keystore/server.jks #using asymmetric encryption
    location: classpath:/server.jks #using asymmetric encryption
    password: springcloudconfig
    alias: testconfigkey
    secret: springcloudconfig       
 # key: springcloudconfig #using symmetric encryption

Any idea on what I am missing? Highly appreciate your help! Spring Boot: 2.0.3 JCE is installed jre/lib location


Solution

  • I just noticed the server.jks file is not present in config server project. After placing the file it decrypted the content properly.

    Source code is available in Github:

    https://github.com/sureshpec04/spring-cloud-config-sample