Ask Your Question

In Spring Boot, how can I conceal passwords in a properties file?

asked 2021-10-15 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-08-17 20:00:00 +0000

david gravatar image

In Spring Boot, you can conceal passwords in a properties file by utilizing the spring.config.encrypt.enabled property. This property will allow you to encrypt sensitive data in your properties file, such as passwords. Here are the steps to conceal passwords:

  1. Generate a secret key: You can generate a secret key using the keytool command as shown below:

    keytool -genkeypair -alias mykey -keyalg RSA -dname "CN=Web Server,OU=Unit,O=Organization,L=City,S=State,C=US" -keypass mypassword -keystore keystore.jks -storepass mystorepassword
  2. Add the secret key to your application: You can add the secret key to your application by specifying the following in your file:


    This will specify the location of the keystore file and the password to access it. It will also specify the alias of the key to use and the password for that key.

  3. Encrypt your password: You can now encrypt your password using the encrypt command. For example, to encrypt the password mypassword, you can use the following command:

    java -jar myapp.jar --encrypt mypassword

    This will encrypt the password using the secret key specified in your file.

  4. Use the encrypted password in your properties file: You can now use the encrypted password in your file as shown below:


    This will use the encrypted password in your application, and Spring Boot will automatically decrypt it using the secret key specified in your file.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2021-10-15 11:00:00 +0000

Seen: 15 times

Last updated: Aug 17 '21