Ryan
Ryan

Reputation: 1232

Unable to get keystore file working with Springboot

I'm trying to setup SSL in my Springboot application to enable HTTPs on my REST API. I'm getting the following failure.

java.security.UnrecoverableKeyException: Password verification failed
Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect

I know the password is correct.

JKS Generation

openssl pkcs12 -export -in sample_cert.cer -inkey sample.key -out out.p12
keytool -importkeystore -srckeystore out.p12 \
        -srcstoretype PKCS12 \
        -destkeystore output.jks \
        -deststoretype JKS

It prompts for a password and I put in tester

Spring Config

server.port=8443

server.ssl.key-alias=1
server.ssl.key-store-type=JKS
server.ssl.key-password=tester
server.ssl.key-store=classpath:output.jks

security.require-ssl=true

Upvotes: 1

Views: 1660

Answers (1)

b.s
b.s

Reputation: 2755

I think you are missing the Keystore password here and only providing the password using which private key is protected. If you're using the same password for the key and Keystore then add the following property and use the same password, otherwise use a different one that you set earlier.

server.ssl.key-store-password =<put keystore password here>

There might be the scenario that you've set the password for only the Keystore but you're using it for the key. So align your configuration in accordance with the Keystore.

Upvotes: 1

Related Questions