Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Cloud Config Server - Where to set encrypt.key to enable /encrypt endpoint

I have a Spring Cloud Config app with the Spring Cloud Security dependencies. I'm trying to hit the /encrypt endpoint to encrypt a password.

According to the docs at http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_key_management I believe I need to set a symmetric key using "encrypt.key". But I can't figure out where to put this; all combinations I've tried result in {"description":"No key was installed for encryption service","status":"NO_KEY"} when I attempt to POST to /encrypt.

If I POST a key to /key, the /encrypt works perfectly, so I'm pretty sure that everything else is setup correctly. It also works fine using the environment variable ENCRYPT_KEY, or by using a system property encrypt.key. I just can't figure out where to place the encrypt.key within a configuration file. Is there a sample on this?

like image 428
Ken Krueger Avatar asked Jan 08 '23 10:01

Ken Krueger


1 Answers

Thanks @pVilaca, this is indeed what the documentation says, but setting the key in application.properties or application.yml won't work.

Through experimentation I've found that the only place you can set the encrypt.key property is an ENCRYPT_KEY environment variable, a system property, bootstrap.properties, bootstrap.yml, or calling the /key endpoint.

Not sure why application.properties or application.yml don't work in this case. Setting this key must have more of an impact on the startup process than it would appear.

like image 111
Ken Krueger Avatar answered Jan 14 '23 04:01

Ken Krueger