1

I have an issue while importing certificate in users keystore for Java. (in appdata\LocalLow\Sun\Java\Deployment\Security).

I already have made scripts to add certificates to the "machine" keystore (in C:\Program Files...) and those works using the default password "changeit". But if I try to use this password (or changeme, which is for Mac OS IIRC), I can't list or import certificate in users keystore, for example trusted.certs and trusted.cacerts. Is there another "default password" for those?

Here is an example of the command I used :

.\keytool.exe -import -file C:\temp\CACERT_G3.cer -keystore "C:\Users\username\AppData\LocalLow\Sun\Java\Deployment\security\trusted.cacerts" -v -storepass "changeit"
erreur keytool : java.io.IOException: Keystore was tampered with, or password was incorrect
java.io.IOException: Keystore was tampered with, or password was incorrect
        at sun.security.provider.JavaKeyStore.engineLoad(Unknown Source)
        at sun.security.provider.JavaKeyStore$JKS.engineLoad(Unknown Source)
        at sun.security.provider.KeyStoreDelegator.engineLoad(Unknown Source)
        at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(Unknown Source)
        at java.security.KeyStore.load(Unknown Source)
        at sun.security.tools.keytool.Main.doCommands(Unknown Source)
        at sun.security.tools.keytool.Main.run(Unknown Source)
        at sun.security.tools.keytool.Main.main(Unknown Source)
Caused by: java.security.UnrecoverableKeyException: Password verification failed
        ... 8 more

(The reason of this requirement is that we have a problem with an app that ignores certicate when we put them in the machine keystore, but if a user manually add the cert is in keystore with the Control Panel GUI, it works. So we have to deploy that solution to 18k+ users)

1 Answer 1

0

The java User trusted.cacerts store is blank by default, like:

keytool -list -storepass "" -keystore .\path\to\Sun\Java\Deployment\Security\trusted.certs

But it is also in user-space, so any user could change the password, delete the keystore, etc.


However, you mention using the Control Panel GUI, certmgr.msc (User) or certlm.msc (System), which manages the windows trust store. These are separate locations, but are used for the same thing

Java can use the windows store with options like -Djavax.net.ssl.trustStoreType=WINDOWS-ROOT, though there are some other settings required, depending on your configuration.

Importing certificates into the windows trusted ca certs would be done with different tools like group policy, cmd (certutil.exe), or powershell, for example

2
  • I think OP meant the Java Control Panel, which through 8 at least (and IIRC 10) does among other things manage the java-deployment store (not the Windows one). Jun 11, 2022 at 3:19
  • Exactly, thanks for the clarification @dave_thompson_085! And sadly, even on a "brand-new" store, the keytool...tool...doesn't work. If I try to use the parameter -storepass "", it return an error saying that storepass expect a value. And if I try to manually left it blank (on prompt), it asks for a PWD again :( Jun 13, 2022 at 13:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .