ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.9k stars 520 forks source link

JASYPT fails to bind properties 'spring.datasource.password' while using with ENC() #371

Open susheelamohan opened 1 year ago

susheelamohan commented 1 year ago

we upgraded spring boot version to 2.7.7 from 2.1.x , when we use

spring.datasource.password=${datasource_password:ENC(xxxxxxxxxxxxxxxx)} it fails to get a DBconnection.

However, with clear text in password, it works.

Did some search on the web and tried most of the suggestions as below:

  1. upgrading/downgrading maven dependency jasypt-spring-boot-starter version 3.x , 2.0.0
  2. passing -Djasypt.encryptor.password= OR -DJASYPT_ENCRYPTOR_PASSWORD= as JVM argument
  3. setting spring.datasource.password=ENC(encrypted_password)
  4. Have also tried setting the combinations of these jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator Default algorithm : jasypt.encryptor.algorithm=PBEWithMD5AndDES
    jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator org.jasypt.salt.RandomSaltGenerator
  5. with/out provider and classname.

it was working with 2.1.x and jasypt 1.18, The provider as BC, clasname : org.bouncycastle.jce.provider.BouncyCastleProvider jasypt.encryptor.algorithm=${encryption_algorithm:PBEWITHSHAAND256BITAES-CBC-BC} jasypt.encryptor.provider=BC

Any pointers on this are highly appreciated.

LemmingAvalanche commented 1 year ago

We had a similar problem. Upgrading from 3.0.4 to 3.0.5 worked for us.

We also had to add @EnableEncryptableProperties to all application classes (classes with @SpringBootApplication).