Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4887561
Votes 98
Synopsis 1.4.2 cannot read keystore written with 1.4.1
Category java:classes_security
Reported Against 1.4.2 , tiger
Release Fixed 1.4.2_05, 1.5(tiger) (Bug ID:2071780)
State 10-Fix Delivered, bug
Priority: 3-Medium
Related Bugs 4887563 , 4896869 , 4900235 , 4901427 , 4900593
Submit Date 08-JUL-2003
Description


FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)


FULL OS VERSION :
 customer  Windows XP [Version 5.1.2600]

EXTRA RELEVANT SYSTEM CONFIGURATION :
Unlimited-strength encryption jars are installed.

A DESCRIPTION OF THE PROBLEM :
I use 1.4.1 to write a keystore to a file, and have no problems reading it back with 1.4.1 (any version of 1.4.1, i.e. 1.4.1_01 through 1.4.1_03). When I try reading it with 1.4.2, I get a StreamCorruptedException.

I found similar problems described in two forum messages, without resolutions.


ERROR MESSAGES/STACK TRACES THAT OCCUR :
(line number in Main.main may be incorrect)
java.io.StreamCorruptedException: invalid stream header
	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:737)
	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:253)
	at com.sun.crypto.provider.JceKeyStore.engineLoad(DashoA6275)
	at java.security.KeyStore.load(KeyStore.java:652)
	at Main.main(Main.java:16)


REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
// sample code for reading from keystore;
// use similar code to generate the keystore and put some keys in it
import java.io.*;
import java.security.*;

public class Main {
  public static void main(String[] args) {
    try {
      final String keyStoreType = "JCEKS";
      final Provider provider = Security.getProvider("SunJCE");
      final char[] keystorePW = ...; // put a password here
      File keyStoreFile = new File("keystore"); // put a filename here
      KeyStore keyStore = KeyStore.getInstance(keyStoreType, provider);

      final InputStream keyStoreStream = new FileInputStream(keyStoreFile);
      keyStore.load(keyStoreStream, keystorePW);
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use 1.4.1
(Review ID: 189941) 
======================================================================
Work Around
N/A
Evaluation
Isn't this a dup of 4887563?

  xxxxx@xxxxx   2003-07-09

Will fix.

yu-  xxxxx@xxxxx   2003-07-14

Here is the cause:
The StreamCorruptedException is thrown by ObjectInputStream/ObjectOutputStream class. Since OIS/OOS actually *read/write* bytes in its *constructor* from the underlying stream, it has to be instantiated at the right place. In addition, closing it would close the underlying stream too.
yu-  xxxxx@xxxxx   2003-08-06
Comments
  
  Include a link with my name & email   

Submitted On 18-JUL-2003
ulibube
Here's a link to a forum discussion with additional information:

http://forum.java.sun.com/thread.jsp?
forum=60&thread=414869


Submitted On 28-NOV-2003
Pie-Fed
The state says closed-fixed, but I just downloaded 1.4.2_02
for w2k, and this bug still exists.


Submitted On 02-DEC-2003
Pie-Fed
Sorry, I didn't understand that "tiger" means 1.5


Submitted On 15-JAN-2004
gt
You guys have got to be kidding me.  You don't plan on 
fixing this in 1.4.2!?!?!?  What's with that?  How can you 
*NOT* fix it for 1.4.2?


Submitted On 28-JAN-2004
mattsecoske
I agree. This needs to be fixed... I have customers that 
are running up against this. 


Submitted On 22-MAR-2004
jtwow
1.5 is not a stable product, 1.4.2_03 is a stable 
product, yet this is marked closed?  What about the 
rest of us using the latest stable builds with real 
customers out there?


Submitted On 26-MAR-2004
bgoetz
We are also forced to stay on jdk 1.3.1_x with a specific 
component with our customers. The migration of the 
keystore costs money so they reject it. Please fix this in 
1.4.2!
Question: *IF* we get the customer to migrate the 
keystore, do we need to remigrate for 1.5?


Submitted On 14-JUN-2004
mark@mindreef.com
Note: it does say fixed in 1.4.2_05, just not sure when that will be out...


Submitted On 14-JUL-2004
ewsachse
I downloaded the 1.4.2_05 JSDK, and it cannot read a keystore I created in 1.4.2_03.

Way to go Sun.


Submitted On 23-JUL-2004
rpisani
I have the same problem... keystore from 1.4.2_03 can't be read in 1.4.2_05... now what am I supposed to do!?!?



PLEASE NOTE: JDK6 is formerly known as Project Mustang