File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Corrupt keystore?" Watch "Corrupt keystore?" New topic
Author

Corrupt keystore?

Mark Fraser
Greenhorn

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");
logger.info("KeyStore: " + ks);
FileInputStream fis = new FileInputStream(certificatePath);
logger.info("FileInputStream: " + fis);
ks.load(fis, privateKeyPassword.toCharArray());
logger.info("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
Greenhorn

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.
 
Consider Paul's rocket mass heater.
 
subject: Corrupt keystore?