'java.io.IOException: Invalid keystore format / Unrecognized keystore format. Please load it with a specified type, when using an old android keystore

I tried to sign an old Android application with Android Studio 4.0.1 (which I successfully signed say, 1 year ago) and it seems the keystore cannot be open anymore. I checked the credentials carefully but I don't think it comes from that. I also checked the various answers with "Invalid keystore format" on the Internet but get no luck here.

The android JRE raises this error:

$ /Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/jre/bin/keytool -list -keystore android.keystore -v
erreur keytool : java.io.IOException: Invalid keystore format
java.io.IOException: Invalid keystore format
    at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:663)
    at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:56)
    at sun.security.provider.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:224)
    at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(JavaKeyStore.java:70)
    at java.security.KeyStore.load(KeyStore.java:1445)
    at sun.security.tools.keytool.Main.doCommands(Main.java:823)
    at sun.security.tools.keytool.Main.run(Main.java:366)
    at sun.security.tools.keytool.Main.main(Main.java:359)

$ /Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/jre/bin/java -version
openjdk version "1.8.0_242-release"
OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
OpenJDK 64-Bit Server VM (build 25.242-b3-6222593, mixed mode)

It is quite the same message with the OS one:

$ keytool -list -keystore android.keystore -v
keytool error: java.security.KeyStoreException: Unrecognized keystore format. Please load it with a specified type
java.security.KeyStoreException: Unrecognized keystore format. Please load it with a specified type
    at java.base/java.security.KeyStore.getInstance(KeyStore.java:1809)
    at java.base/java.security.KeyStore.getInstance(KeyStore.java:1680)
    at java.base/sun.security.tools.keytool.Main.doCommands(Main.java:936)
    at java.base/sun.security.tools.keytool.Main.run(Main.java:417)
    at java.base/sun.security.tools.keytool.Main.main(Main.java:410)

$ java --version
openjdk 14.0.2 2020-07-14
OpenJDK Runtime Environment (build 14.0.2+12-46)
OpenJDK 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

I think I have already met this issue in the past and had to revert to an older version of the JRE to keep on opening my keystore properly (solution I am currently trying now).

  • Is this a question of default algorithm that changed between versions? If yes, how can I check my keystore is still valid and that I use a correct algorithm (since I did not create it unfortunately)?
  • Do I need to migrate the keystore somehow?


Solution 1:[1]

I think I have already met this issue in the past and had to revert to an older version of the JRE to keep on opening my keystore properly (solution I am currently trying now).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 minhtu