0

My code

    String[] command = {
            "-list",
            "-keystore",
            keystoreFile.getAbsolutePath(),
            "-storepass",
            password
        };
    try {
        sun.security.tools.keytool.Main.main(command);
    } catch (Exception e) {
        e.printStackTrace();
    }

I don't get why the exception is not caught and error message is shown, after that the program is terminated:

keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect

I believe it might be caused by keytool, it doesn't throw anything at all, but just prints the error message and ends the program. If it's so, how I can run keytool and verify that the given configuration is fine and no any errors are here?

Steve Warner
  • 15
  • 1
  • 7
  • Your assumption is most probably correct. `keytool` seems to catch the exception internally and print this message. As to the cause: [this question](http://stackoverflow.com/questions/16891182/keytool-error-keystore-was-tampered-with-or-password-was-incorrect) might provide some insight. – Turing85 Apr 22 '17 at 20:43
  • @Turing85, no, they have problems with guessing passwords and generating new keystores, but I need to check somehow that the provided configuration is correct – Steve Warner Apr 22 '17 at 20:48
  • 2
    don't you consider using the java api e.g. `java.security.KeyStore` instead of the command line tool? – nandsito Apr 22 '17 at 21:19

0 Answers0