ulisesbocchio / jasypt-spring-boot

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

spring boot 1.5.15, jasypt-spring-boot-starter 2.0.0 and jasypt-1.9.2 cli , application fails to decrypt #226

Closed srinikasarla closed 3 years ago

srinikasarla commented 4 years ago

spring boot - 1.5.15 jasypt-spring-boot-starter - 2.0.0 jasypt cli -1.9.2 CLI and application running on centos

Using cli to encrypt passwords ./encrypt.sh input="somedbpassword" password="jasyptpwd" algorithm="PBEWITHHMACSHA512ANDAES_256" encypted value - nokz6eonaoeYEMWL30jXT8zBMRS1gcrWsGlt3tUVAHU=

pom.xml

<dependency>
      <groupId>com.github.ulisesbocchio</groupId>
      <artifactId>jasypt-spring-boot-starter</artifactId>
      <version>2.0.0</version>
    </dependency>

application.properties

jasypt.encryptor.algorithm=PBEWITHHMACSHA512ANDAES_256
jasypt.encryptor.password=jasyptpwd
spring.datasource.password=ENC(nokz6eonaoeYEMWL30jXT8zBMRS1gcrWsGlt3tUVAHU=)
Caused by: com.ulisesbocchio.jasyptspringboot.exception.DecryptionException: Decryption of Properties failed,  make sure encryption/decryption passwords match
        at com.ulisesbocchio.jasyptspringboot.resolver.DefaultPropertyResolver.resolvePropertyValue(DefaultPropertyResolver.java:37)
        at com.ulisesbocchio.jasyptspringboot.resolver.DefaultLazyPropertyResolver.resolvePropertyValue(DefaultLazyPropertyResolver.java:41)
        at com.ulisesbocchio.jasyptspringboot.EncryptablePropertySource.getProperty(EncryptablePropertySource.java:16)
        at com.ulisesbocchio.jasyptspringboot.wrapper.EncryptableMapPropertySourceWrapper.getProperty(EncryptableMapPropertySourceWrapper.java:29)
        at org.springframework.boot.bind.PropertySourcesPropertyValues.getEnumerableProperty(PropertySourcesPropertyValues.java:166)
        at org.springframework.boot.bind.PropertySourcesPropertyValues.processEnumerablePropertySource(PropertySourcesPropertyValues.java:149)
        at org.springframework.boot.bind.PropertySourcesPropertyValues.processPropertySource(PropertySourcesPropertyValues.java:128)
        at org.springframework.boot.bind.PropertySourcesPropertyValues.<init>(PropertySourcesPropertyValues.java:118)
        at org.springframework.boot.bind.PropertiesConfigurationFactory.getPropertySourcesPropertyValues(PropertiesConfigurationFactory.java:331)
        at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:285)
        at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:250)
        at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:331)
        ... 133 more
Caused by: org.jasypt.exceptions.EncryptionOperationNotPossibleException
        at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.decrypt(StandardPBEByteEncryptor.java:1051)
        at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:725)
        at org.jasypt.encryption.pbe.PooledPBEStringEncryptor.decrypt(PooledPBEStringEncryptor.java:498)
        at com.ulisesbocchio.jasyptspringboot.encryptor.DefaultLazyEncryptor.decrypt(DefaultLazyEncryptor.java:82)
        at com.ulisesbocchio.jasyptspringboot.resolver.DefaultPropertyResolver.resolvePropertyValue(DefaultPropertyResolver.java:35)

Default algorithm is working but application does not decrypt with PBEWITHHMACSHA512ANDAES_256 algorithm.

I have tried with and without https://download.oracle.com/otn-pub/java/jce/8/jce_policy-8.zip jars. Does jasypt 1.9.2 support PBEWITHHMACSHA512ANDAES_256 algorithm? Do I need to enable/install to make it work?

ulisesbocchio commented 3 years ago

PBEWITHHMACSHA512ANDAES_256 not supported in Jasypt 1.9.2, you need to upgrade to a newer version of jasypt-spring-boot