Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SSL handshake problem using IPv6 addresses

843790Oct 8 2008 — edited Jan 28 2009
Hi,

I am facing a problem writing data to a SSLSocket using the OutputStream of the SSLSocket. This problem happens only when we are creating the socket using an IPv6 address (except the link local ipv6 address). I am using java 1.5.

SocketFactory m_socketFactory = SocketFactory.getDefault();
SocketAddress m_addrSocket = new InetSocketAddress(m_addr, m_iPort);
Socket s = m_socketFactory.createSocket();
s.connect(m_addrSocket);

InputStream strmIn = s.getInputStream();
OutputStream strmOut = s.getOutputStream();

// Then i am trying to create a HTTP message and then convert it to bytestream and then trying to write it to the
// output stream of the Socket.
strmOut.write(buf.toString().getBytes())

The write call fails after sometime with exception saying "Remote host closed connection during handshake". The write call actually taking a lot of time to write the data to write and in the mean time the server closes down the SSL handshake process.

This problem doesnot happen when we try to access the server using ipv4 address or a ipv6 link local address. In these scenarios, the write call finishes very fast. But, in case of other ipv6 address (i.e. stateless address and DHCPv6 addresses), the write api call takes a long time which in turn gives the exception.

I am getting following exception

jvm 1 | Caused by: javax.net.ssl.SSLHandshakeException: Remote host closed co
nnection during handshake
jvm 1 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(Unknown
Source)
jvm 1 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHand
shake(Unknown Source)
jvm 1 | at com.sun.net.ssl.internal.ssl.SSLSocketImpl.writeRecord(Unknow
n Source)
jvm 1 | at com.sun.net.ssl.internal.ssl.AppOutputStream.write(Unknown So
urce)
jvm 1 | at java.io.OutputStream.write(Unknown Source)

Could anybody guide me as to what could be the fix for this problem?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 25 2009
Added on Oct 8 2008
7 comments
716 views