ulisesbocchio / jasypt-spring-boot

Jasypt integration for Spring boot
MIT License
2.91k stars 522 forks source link

Failed to bind properties under '...' to java.lang.String` - Spring Boot 2.5.6 #300

Closed diegonobrega closed 1 year ago

diegonobrega commented 2 years ago

Hello. I know that this problem already is knowed but I literally followed all suggestions but even that I couldn't fix this yet. I'm using Java 11, Spring Boot 2.5.6. Could the reason for that be the Spring Boot version? The readme project file says that it supports until the 2.0.x version.

I followed all sugestions from this Issue: https://github.com/ulisesbocchio/jasypt-spring-boot/issues/154/ and specially this one: 154/#issuecomment-776315949

I just encrypted the plain text using > encrypt.bat input="myinput" password=mypassword algorithm=PBEWithMD5AndTripleDES. After that I added the gradle dependence of the 3.0.4 version and put the output generated in the application.properties file:

jasypt.encryptor.password=mypassword
jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator
jasypt.encryptor.algorithm=PBEWithMD5AndTripleDES
server.ssl.key-store=classpath:miuey.jks
server.ssl.key-store-type=pkcs12
server.ssl.key-store-password=ENC(qaYXLbFSPsr/8S9hrGU+hbYSu/fmLdW4)
server.ssl.key-password=ENC(qaYXLbFSPsr/8S9hrGU+hbYSu/fmLdW4)
server.ssl.key-alias=miuey
server.port=8443

After that I started the Spring Boot app with embedded Tomcat and I can see this in the console (what means that the dependence was recognized) but the error blows up failed to bind properties under.. to java.lang.String:

Encryptor config not found for property jasypt.encryptor.key-obtention-iterations, using default value: 1000
Encryptor config not found for property jasypt.encryptor.pool-size, using default value: 1
Encryptor config not found for property jasypt.encryptor.provider-name, using default value: null
Encryptor config not found for property jasypt.encryptor.provider-class-name, using default value: null
Encryptor config not found for property jasypt.encryptor.salt-generator-classname, using default value: org.jasypt.salt.RandomSaltGenerator
Encryptor config not found for property jasypt.encryptor.string-output-type, using default value: base64

Description:
Failed to bind properties under 'server.ssl.key-password' to java.lang.String:

The problem is the version right? Because I run a lot of tutorials and that #154 Issue completely and even that couldnt solve this :(

warrengoldman commented 2 years ago

yep, same, really not sure what the current version is...

andyolivares commented 2 years ago

Having the same problem here with Spring Boot 2.6.11 and Jasypt Spring Boot 3.0.4. Defaults never worked. I had to set the following to application.properties:

jasypt.encryptor.password=${JASYPT_PASSWORD:XXXX} jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator jasypt.encryptor.algorithm=PBEWithMD5AndTripleDES

It didn't even worked passing jasypt.encryptor.password any other way (eg. using -D switch). Plase make defaults work with recent versions of Spring Boot and Java 8/11.

ulisesbocchio commented 1 year ago

3.0.5 is out. Reopen if still an issue