ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.88k stars 516 forks source link

jasypt-spring-boot-starter : Not able to decrypt the properties #182

Closed gubbaraja closed 4 years ago

gubbaraja commented 4 years ago

We are using jasypt-spring-boot-starter:2.1.1 and spring-boot:1.5.x. Jasypt library was able to decrypt the properties with out any issues until we upgraded spring-boot to 2.1.x. We are getting the below exception while trying to decrypt the values.

19:48:08 Caused by: com.ulisesbocchio.jasyptspringboot.exception.DecryptionException: Decryption of Properties failed, make sure encryption/decryption passwords match 19:48:08 Caused by: org.jasypt.exceptions.EncryptionOperationNotPossibleException 1

We have all the necessary configuration in place for jasypt library to be able to decrypt the values. Can you please let us know what the issue could be?

lz1asl commented 4 years ago

See https://github.com/ulisesbocchio/jasypt-spring-boot/blob/master/README.md#update-11242019-version-300-release-includes, you need

jasypt:
  encryptor:
    algorithm: PBEWithMD5AndDES
    iv-generator-classname: org.jasypt.iv.NoIvGenerator

to use your existing code

gubbaraja commented 4 years ago

@lz1asl We are still using 2.1.1 version of jasypt-spring-boot-starter. Are you saying that we need to provide the additional configuation you mentioned even for 2.1.1 version

ulisesbocchio commented 4 years ago

@gubbaraja Spring Boot 2.1.X needs jasypt-spring-boot 3.0.0 and the property mentioned by @lz1asl

ulisesbocchio commented 4 years ago

I updated the readme to make it more clear. Let me know when you try this

gubbaraja commented 4 years ago

Thanks @ulisesbocchio . I updated the configuration in my application.yml as below. Also, i am using spring-boot:2.1.x with jasypt-spring-boot-starter:3.0.0

jasypt:
   encryptor:
     algorithm: PBEWithMD5AndDES
     iv-generator-classname: org.jasypt.iv.NoIvGenerator
     password: xxxxxxxxx

But, i am still the same error.

Caused by: com.ulisesbocchio.jasyptspringboot.exception.DecryptionException: Unable to decrypt: ENC(xxxxxxxxx). Decryption of Properties failed,  make sure encryption/decryption passwords match
    at com.ulisesbocchio.jasyptspringboot.resolver.DefaultPropertyResolver.lambda$resolvePropertyValue$0(DefaultPropertyResolver.java:46) ~[jasypt-spring-boot-3.0.0.jar:?]

Can you please let me know if i am missing any configuration required

ulisesbocchio commented 4 years ago

can you re-encrypt the properties? what was you configuration before?

gubbaraja commented 4 years ago

Thanks @ulisesbocchio .It worked after updating the configuration and re-encrypting the properties.

My previous configuration was :

jasypt:
   encryptor:
     password: xxxxxxxxx