Jasypt out of maintenance? What to use for encryption with Spring Boot

Viewed 471
1 Answers

Spring Cloud has builtin support for decrypting properties. Any property that starts with {cipher}... will automatically be decrypted at runtime. Similar to jasypt, a 'master' encryption key is used. Configuring this key can be done by specifying encrypt.key in bootstrap.yaml or by specifying the ENCRYPT_KEY environment variable. Default uses symmetric encryption, but it's also possible to use asymmetric keys.

spring:
  datasource:
    password: {cipher}xxxxx

The Spring CLI also has support for encrypting values:

spring encrypt --key MySeCrEtMaStErKeY 'secretAPIkey'

Then start your app by specifying the master encryption key in bootstrap.yaml or using an environment variable:

ENCRYPT_KEY=MySeCrEtMaStErKeY java -jar myapp.jar

See https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#encryption-and-decryption

For more sophisticated setups, I highly recommend using Hashicorp Vault. It's open source and free to use.

Related