Reputation: 1971
I'm currently working on a an application with a microservice architecture. I have two services for now: product service and configuration service.
The configuration service plays the role of spring cloud config server, while the product service plays the role of spring cloud config client.
To launch my application, the configuration service should be run first, and then product service, this way product service can ask its configuration (application.properties) file to set up its connection to database etc. What I want now is to encrypt some sensitive properties like database credentials. Why? 'cause if you reach the endpoint of the cloud config service http://localhost:8888/productservice/env you can find these informations as plain text, which is not good.
For the time being I thought to use symetric encryption so following the documentation if I set a variable environement in my OS as ENCRYPT_KEY, my spring cloud config server should encrypt and decrypt my data.
I'm using windows 10 and using the set command I can see that the ENCRYPT_KEY is set properly with the correct secret word.
However when I try to reach the /encrypt endpoint with a POST method of my cloud config server, it responds with a 404 not found:
{
"description": "No key was installed for encryption service",
"status": "NO_KEY"
}
I'm using Edgware.RELEASE version of spring-cloud.
Thank you
Upvotes: 2
Views: 2389
Reputation: 1782
I think the problem is that you set the environment variable with the set command. When you set a variable with the set command that variable is available only in that CMD session.
What you need is to make the variable visible in your App. To achieve that you can set the environment variable through the System Properties option (tap Windows
key and type edit the system environment variables
).
Also make sure your app can read the variable value by doing something like System.getenv("ENCRYPT_KEY")
in your Application main
method.
By the way, if you are using Eclipse you can set environment variables in Run, Run Configurations..., Environment tab.
Upvotes: 2