ulisesbocchio / jasypt-spring-boot

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

Not able to decrypt using jasypt maven plugin with 3.0.0 #177

Closed bjornharvold closed 4 years ago

bjornharvold commented 4 years ago

My application-local.properties file is located under ./src/main/resources. Encryptor password is correct. The application starts fine and I can confirm the encrypted password is decrypted into its correct string.

I have not been able to get this utility to work.

mvn jasypt:decrypt -Djasypt.encryptor.password="MXyXswPQkxRanB3VXNMgYY2JJRYngE?aun(bHkVJK6PN4aYjT}/^ueLtex(R78W4" -Dspring.profiles.active=local -Djasypt.encryptor.algorithm=PBEWithMD5AndTripleDES
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< com.protractinator:protractinator-web-api >-------------------
[INFO] Building Protractinator Web API (Spring Boot) 11.0.27-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- jasypt-maven-plugin:3.0.0:decrypt (default-cli) @ protractinator-web-api ---
[INFO] Starting MavenCli v3.6.3 on crash.local with PID 1618 (/usr/local/Cellar/maven/3.6.3/libexec/lib/maven-embedder-3.6.3.jar started by crash in /Users/crash/git/protractinator/protractinator-web-api)
[INFO] The following profiles are active: local
[INFO] Post-processing PropertySource instances
[INFO] Converting PropertySource configurationProperties [org.springframework.boot.context.properties.source.ConfigurationPropertySourcesPropertySource] to AOP Proxy
[INFO] Converting PropertySource systemProperties [org.springframework.core.env.PropertiesPropertySource] to EncryptableMapPropertySourceWrapper
[INFO] Converting PropertySource systemEnvironment [org.springframework.boot.env.SystemEnvironmentPropertySourceEnvironmentPostProcessor$OriginAwareSystemEnvironmentPropertySource] to EncryptableSystemEnvironmentPropertySourceWrapper
[INFO] Converting PropertySource random [org.springframework.boot.env.RandomValuePropertySource] to EncryptablePropertySourceWrapper
[INFO] Property Filter custom Bean not found with name 'encryptablePropertyFilter'. Initializing Default Property Filter
[INFO] Started MavenCli in 0.69 seconds (JVM running for 3.901)
[INFO] Decrypting file src/main/resources/application-local.properties
[INFO] String Encryptor custom Bean not found with name 'jasyptStringEncryptor'. Initializing Default String Encryptor
[INFO] Property Resolver custom Bean not found with name 'encryptablePropertyResolver'. Initializing Default Property Resolver
[INFO] Property Detector custom Bean not found with name 'encryptablePropertyDetector'. Initializing Default Property Detector
[INFO] Encryptor config not found for property jasypt.encryptor.key-obtention-iterations, using default value: 1000
[INFO] Encryptor config not found for property jasypt.encryptor.pool-size, using default value: 1
[INFO] Encryptor config not found for property jasypt.encryptor.provider-name, using default value: null
[INFO] Encryptor config not found for property jasypt.encryptor.provider-class-name, using default value: null
[INFO] Encryptor config not found for property jasypt.encryptor.salt-generator-classname, using default value: org.jasypt.salt.RandomSaltGenerator
[INFO] Encryptor config not found for property jasypt.encryptor.iv-generator-classname, using default value: org.jasypt.iv.RandomIvGenerator
[INFO] Encryptor config not found for property jasypt.encryptor.string-output-type, using default value: base64
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.936 s
[INFO] Finished at: 2019-12-09T08:47:08+07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.ulisesbocchio:jasypt-maven-plugin:3.0.0:decrypt (default-cli) on project protractinator-web-api: Execution default-cli of goal com.github.ulisesbocchio:jasypt-maven-plugin:3.0.0:decrypt failed.: EncryptionOperationNotPossibleException -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
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

ulisesbocchio commented 4 years ago

are you passing the password to the mvn command?

bjornharvold commented 4 years ago

Hi @ulisesbocchio . Yes, passing the password as shown above. Hi @lz1asl . Thank you. That did the trick.

This works: mvn jasypt:decrypt -Djasypt.encryptor.password="MXyXswPQkxRanB3VXNMgYY2JJRYngE?aun(bHkVJK6PN4aYjT}/^ueLtex(R78W4" -Dspring.profiles.active=local -Djasypt.encryptor.algorithm=PBEWithMD5AndTripleDES -Djasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator