I am getting java.io.StreamCorruptedException when I try to access a keystore file. The keystore was generated using JDK 1.2.2 (old application) and I am trying to access the same code that ran in Weblogic 5.1 under JDK 1.2.2 in JBoss 4.0.2 using JDK 1.4.2. The JCE jar version that I am using with JDK 1.2.2 is JCE 1.2.
I did a test where I tried to invoke an independant java program which loads the keystore under JDK 1.4.2 and it worked absolutely fine. The code that I used in this small program is the same exact one that gets invoked inside the web application.
The exception I am getting is -
The code that is being used is -
Provider sunJce = new com.sun.crypto.provider.SunJCE();
KeyStore ks = KeyStore.getInstance("JCEKS", "SunJCE");
FileInputStream is = new FileInputStream(keyStoreFile);
What can be the problem. Please help. I am really stuck here.
I myself found the problem. In my build.xml the ant task to copy the keystore to the proper location had filtering="true" for tokens. This was somehow messing up the keystore and it was getting modified. Removing the filtering solved the problem. So the keystore was getting corrupt and the exception was perfectly valid.