The moose likes Security and the fly likes Corrupt keystore? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "Corrupt keystore?" Watch "Corrupt keystore?" New topic

Corrupt keystore?

Mark Fraser

Joined: Oct 15, 2010
Posts: 11
Our host recently performed a server migration (mirror of the old environment) but now I can't load the keystore, even though the SSL setup still works.

My problem is when I try to load the keystore to access the private key I get a null pointer exception. The keystore documentation doesn't mention a null pointer exception but I've seen this error before when I tried using the wrong password. If the environment is a mirror of the old environment then the password, etc. should all be the same. Can anyone suggest what may have happened?

In the code below, the "KeyStore loaded" string doesn't get logged.

if (Security.getProvider("BC") == null) {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());

// Read the Private Key
KeyStore ks = KeyStore.getInstance("PKCS12", "BC");"KeyStore: " + ks);
FileInputStream fis = new FileInputStream(certificatePath);"FileInputStream: " + fis);
ks.load(fis, privateKeyPassword.toCharArray());"KeyStore loaded");
Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

Did you contact your host?

It looks like one of fis or privateKeyPassword is null, right? Can you do something to figure out which is null?
Mark Fraser

Joined: Oct 15, 2010
Posts: 11
The problem turned out to be they didn't copy the upgraded signed security policy jar files from the old server.
I agree. Here's the link:
subject: Corrupt keystore?
It's not a secret anymore!