0

I'm using the below code to attempt to load a keystore file and I'm getting an java.io.IOException: Invalid keystore format Exception. Any ideas on how to troubleshoot this or what is causing the issue?

Load Keystore File:

final FileInputStream keyFile = new FileInputStream(filePath
                    + "key.p7b");
            final KeyStore keyStore = KeyStore.getInstance("JKS");
            String storepass = "pwd";
            keyStore.load(keyFile, storepass.toCharArray());

Exception:

java.io.IOException: Invalid keystore format
    at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:633)
    at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:38)
    at java.security.KeyStore.load(KeyStore.java:1185)
6
  • Why should p7b be a valid keystore? Commented Feb 17, 2012 at 0:11
  • that was the keystore file I was sent.. Commented Feb 17, 2012 at 0:12
  • If that's a keystore file you were sent, how did you try generating a new version of it? Commented Feb 17, 2012 at 0:24
  • ignore that statement, I don't have control over the keystore file creation, just the loading of the file. Commented Feb 17, 2012 at 0:29
  • p7b is a certificate file, not a keystore file. You must convert it first. Apparently OpenSSL can help with that. Commented Feb 17, 2012 at 9:17

2 Answers 2

1

On request, my comment as an answer:

p7b is a certificate file, not a keystore file. You must convert it first. Apparently OpenSSL can help with that.

Sign up to request clarification or add additional context in comments.

Comments

0

I have a problema like that when I try to create a keystore file with a Sun/Oracle JDK in Portuguese... The portuguese version of JDK (or my Windows PT-BR, I don't know yet) have this bug... I needed to make the keystore file in an English operational system.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.