The configuration obtained from the configuration is plaintext by default. If some configurations like data sources need to be encrypted, the configuration center needs to be encrypted.
The following uses symmetric encryption to encrypt the configuration. You need to configure a key. Of course, RSA asymmetric encryption can also be used, but symmetric encryption is more convenient and sufficient. Here, symmetric encryption is just configured with symmetric encryption.
1. Install JCE
JCR under JDK has a length limit by default, and it is necessary to replace the JCE version without a length limit.
http://www.oracle.com/technet...
Copy and replace the two jar files in the download package to the JAVA_HOME/jre/lib/security directory.
2. Add encrypted KEY
Add the encryption key to the configuration center configuration file.
encrypt: key: 0e010e17-2529-4581-b907-c8edcfd6be09
3. Check the encryption function status
http://192.168.1.237:7100/encrypt/status
OK will be displayed if the function is normal
{"status":"OK"}
4. Encryption and decryption
Encrypt develop strings
curl http://192.168.1.237:7100/encrypt -d develop -u config-user:99282424-5939-4b08-a40f-87b2cbc403f6
Decrypt the develop string
curl http://192.168.1.237:7100/decrypt -d 0fb593294187a31f35dea15e8bafaf77745328dcc20d6d6dd0dfa5ae753d6836 -u config-user:99282424-5939-4b08-a40f-87b2cbc403f6-u username:password is basic authentication
5. Configuration file
spring: datasource: username: '{cipher}0fb593294187a31f35dea15e8bafaf77745328dcc20d6d6dd0dfa5ae753d6836' Content that needs to be encrypted starts with {cipher} and be careful to wrap the quotation marks in single quotes, otherwise an error will be reported.
6. Read the configuration
In this way, the configuration read by the client is automatically decrypted. If you want to turn off the automatic decryption function and decrypt it yourself, you must also keep the encrypted and decrypted endpoints, you can turn off the following configurations.
spring.cloud.config.server.encrypt.enabled=false
Summarize
The above is the configuration method of Spring Cloud Configuration Center content encryption introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!