Failed to bind properties under 'spring.datasource.password' to java.lang.String`

See original GitHub issue

getting several errors I have tried setting this up with first option it says

"encryptable properties will be enabled across the entire Spring Environment "

I am not sure where to put the password or how it knows what the password is to decrypt it

I have the encoded input in my property file like so

spring.datasource.password=ENC(du+QBwMsZb4kXSQI/eIL1RU46vtOgYZU)

Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.datasource.password' to java.lang.String

Caused by: org.springframework.cache.Cache$ValueRetrievalException: Value for key 'spring.datasource.password' could not be loaded using 'com.ulisesbocchio.jasyptspringboot.caching.CachingDelegateEncryptablePropertySourc

Caused by: java.lang.IllegalStateException: either 'jasypt.encryptor.password' or one of ['jasypt.encryptor.privateKeyString', 'jasypt.encryptor.privateKeyLocation'] must be provided for Password-based or Asymmetric encryption

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:30 (4 by maintainers)

github_iconTop GitHub Comments

23reactions
ulisesbocchiocommented, Dec 30, 2019

If you were using default config before 3.0.0 (Major release, breaking changes) you need to set:

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

Since the default algorithm changed, to keep your encrypted properties. Otherwise, you have to re-encrypt your properties.

9reactions
costalopes71commented, Feb 23, 2021

Hey guys… I faced the same problem as you all… I managed to make it work by doing the following:

  • 1st: encrypt your password using PBEWithMD5AndTripleDES algorithm, example: ./encrypt.sh input="admin123" password=<myEncryptionPassword> algorithm=PBEWithMD5AndTripleDES

  • 2st: After doing that, in your application.properties include these properties:

jasypt.encryptor.password=<yourPassword>
jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator
jasypt.encryptor.algorithm=PBEWithMD5AndTripleDES

It worked fine for me. Im using: jasypt-spring-boot-starter 3.0.3 spring-boot 2.4.2

Hope that help you guys. Cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to bind properties under 'spring.datasource.password ...
Try adding it as an argument when running your app; e.g. -Djasypt.encryptor.password={my password} & see if that works. …
Read more >
Using encrypted password for database connection in spring ...
password=key in properties file. Now i am getting the below error: Failed to bind properties under 'spring.datasource.password' to java.lang.
Read more >
Failed to bind properties under 'spring.datasource.password ...
Description:Failed to bind properties under 'spring.datasource.password' to java.lang.String: Reason: Failed to bind properties under 'spring. ...
Read more >
Secret Key Sharing Issue and Solution
Reason: Failed to bind properties under 'spring.datasource.password' to java.lang.String. Action: Update your application's configuration.
Read more >
Spring Boot JASYPT Failure Failed to bind properties under ...
Coding example for the question Spring Boot JASYPT Failure Failed to bind properties under 'spring.datasource.password'-Springboot.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found