ulisesbocchio / jasypt-spring-boot

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

Password is not ASCII #138

Closed nishiichinoe closed 5 years ago

nishiichinoe commented 5 years ago

I started to use Jasypt in spring-boot with the maven dependency:

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

My spring-boot starter class has these annotations:

@EnableEncryptableProperties
@PropertySource(name="EncryptedProperties", value = "classpath:application.properties")

I encrypted my password like this:

java -cp jasypt-1.9.2.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input=password
password=mySecretalgorithm=PBEWithMD5AndDES

and added the property like this to my application.properties:

server.ssl.key-store-password: ENC(jasyptEncString)

At start I have this command line argument: --jasypt.encryptor.password=mySecret

But it is failing with:

_Failed to bind properties under 'server.ssl.key-store-password' to java.lang.String:

Reason: Password is not ASCII_

The password I checked, it contains only ASCII characters.

If I add this argument (which is actually the default): --jasypt.encryptor.algorithm=PBEWithMD5AndDES

I'm getting:

SecretKeyFactory not available

ulisesbocchio commented 5 years ago

did you figure it out?

nishiichinoe commented 5 years ago

It's a while ago, but as far as I remember I had to write the password clear into the property file and at the first startup of the application it got encrypted. After that everything was fine.

ulisesbocchio commented 5 years ago

Ok, I’m gonna close this issue then. Feel free to reopen or create a new one if you see that again

dylankolson commented 3 years ago

@nishiichinoe I am having the same issue but am not following how you solved it.

ssl:
      key-store: classpath:dev/localhost.jks
      key-store-password: ENC(ram5FwW1dJX0n46mF/gMy+Y4fXGPVxMW/u2UkS2P0JwiCbIxU3d1J42hByf6czGU2gdYNZJw9rQ=)
      keyStoreType: JKS
      keyAlias: localhost
      clientAuth: want
      trust-store: classpath:dev/localhost.jks

javax:
    net:
        ssl:
            keyStore: src/main/resources/dev/localhost.jks
            keyStorePassword: ENC(ram5FwW1dJX0n46mF/gMy+Y4fXGPVxMW/u2UkS2P0JwiCbIxU3d1J42hByf6czGU2gdYNZJw9rQ=)
            trustStore: src/main/resources/dev/localhost.jks
            keyStoreType: JKS`

key-store-password fails saying it cant bind to a string but the keyStorePassword and other ENC(..) work in the yaml fine.