javax.net.ssl.SSLHandshakeException

I am trying to connect to an iplanet using a URLConnection object and I build this object using an https URL. I set all the properties before I try to obtain the output stream on this connection. When I do connection.getOutputStream() it throws the exception below.

I am using an applet that opens these connections. The problem is this happens with Windows XP and JRE 1.4.2_03 combination but not with NT and JRE 1.3. Don't know if the OS version matters but putting it across anyways. This seems to happen after a while the applet has been up and running and opening connections. Also, I tried to tweak the iplanet settings by disabling keep-alive for these clients but in vain.

This has been causing a lot of problems for me and I would appreciate if someone can help me out here.

javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(Unknown Source)

at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(Unknown Source)

at sun.net.www.protocol.https.HttpsClient.afterConnect(Unknown Source)

at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.setNewClient(Unknown Source)

at sun.net.www.protocol.https.PluginDelegateHttpsURLConnection.superConnect(Unknown Source)

at sun.net.www.protocol.https.PluginDelegateHttpsURLConnection.connect(Unknown Source)

at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)

at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)

at poslite.apm.core.APMManagerProxy.communicateWithAPMServlet(APMManagerProxy.java:918)

at poslite.apm.core.APMManagerProxy.processTransaction(APMManagerProxy.java:682)

at com.ncr.ExpressStation.doTransaction(ExpressStation.java:3837)

at com.ncr.ExpressStation.do_IPC(ExpressStation.java:3990)

at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at sun.plugin.com.MethodDispatcher.invoke(Unknown Source)

at sun.plugin.com.DispatchImpl.invokeImpl(Unknown Source)

at sun.plugin.com.DispatchImpl$2.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

at sun.plugin.com.DispatchImpl.invoke(Unknown Source)

Caused by: java.io.EOFException: SSL peer shut down incorrectly

at com.sun.net.ssl.internal.ssl.InputRecord.read(Unknown Source)

... 21 more

[2651 byte] By [atldudea] at [2007-10-1 21:49:39]
# 1

Hello all,

Here is the code. I am getting the SSLHandshakeException at the getOutputStream() call sporadically. It happens with JRE1.4.2_03 client but not with JRE 1.3 client. The server is a SUN web server configured to use SSL v2/3 and TLSv1.

Need some help...

try {

URL url = new URL(path);

URLConnection conn = url.openConnection();

conn.setDoInput(true);

conn.setDoOutput(true);

conn.setUseCaches(false);

conn.setDefaultUseCaches(false);

conn.setAllowUserInteraction(true);

conn.setRequestProperty("CONTENT_TYPE","application/x-java-serialized-object");

debug("connected to " + path);

Vector requestData = new Vector();

requestData.add(command);

requestData.add(hostName);

ObjectOutputStream writer = newObjectOutputStream(conn.getOutputStream());

writer.writeObject(requestData);

debug("wrote '" + command + "' to output stream");

writer.flush();

writer.close();

debug("The response code is "+conn.getResponseCode());

debug("The response message is "+conn.getResponseMessage());

ObjectInputStream reader = new ObjectInputStream(conn.getInputStream());

setSessionId((String)reader.readObject());

debug("The session id is "+getSessionId());

try

{

reader.close();

}

catch(Exception e)

{

debug("unable to close input stream" + e);

}

}

}

catch(Exception e)

{

e.printStackTrace();

}

atldudea at 2007-7-13 7:52:39 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2

In my experience, these kinds of problems can be very difficult to diagnose. I think you are correct in asking in these forums if someone else has had the problem and has solved it. You might also post to USENET newgroups lie comp.lang.java.security and comp.lang.java.programmer.

It might also help to have a a packet capture saved off that encompasses the events you are seeing. Also, check the server's logs -- they should contain the reason the server closed the connection.

ghstarka at 2007-7-13 7:52:39 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 3
Thanks. I have already posted in the comp.lang.java.security group. I am desperate for some light at the end of the tunnel.
atldudea at 2007-7-13 7:52:39 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...