Keystore was tampered with, or password was incorrect - Java Springboot app

Viewed 8371

I know this question has been asked multiple times but I still can't seem to get around it. I'm trying to connect to Azure-SQL db from my SpringBoot app and keep running into this error :

Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:783) ~[na:1.8.0_251]
Caused by: java.security.UnrecoverableKeyException: Password verification failed

I've a rapidssl.jks file that I'm adding to the app's VM args to get past something similar to "PKIX path building failed" and "unable to find valid certification path to requested target"

I'm on MacBook and have tried to create a self signed certificate using:

sudo keytool -export -keystore rapidssl-36.1.2.jks -file selfsign.crt 

and importing it using: sudo keytool -import -keystore "cacerts" -file "/Users/Documents/cert/selfsign.crt" -alias rapidssl running in /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre/lib/security directory. I completed those steps but still can't get past the error. Any suggestions/recommendations?

I'm on Java 8 (zulu jdk), SpringBoot: 2.0.4-RELEASE, MacBook OS Catalina 10.15.7

2 Answers

The quotes in your command seem to be the issue:

sudo keytool -import -keystore "cacerts" -file "/.../selfsign.crt" ...

The keystore cacerts, as well as the file shouldn't be in between quotes.

You already execute it on the right path (jre/lib/security), so try this:

sudo keytool -import -keystore cacerts -file /.../selfsign.crt -alias rapidssl

An example of the keytool command:

enter image description here

Add all of the below properties:

  1. server.ssl.key-store
  2. server.ssl.key-store-type=JKS
  3. server.ssl.key-store-password
  4. server.ssl.key-alias
  5. server.ssl.key-password
Related