title: java6 HttpsUrlConnection error:javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
body: <p>I write a demo to access a server with java HttpsUrlConnection.
  I implement the X509TrustManager interface with MyX509TrustManager to trust all certificates.</p>
  
  <p>It works fine with JDK7 and JDK8, but when use JDK6 and JDK5, error happens:</p>
  
  <pre><code>javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:882)
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1188)
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1215)
  at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1199)
  at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)
  at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)
  at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1014)
  at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:230)
  </code></pre>
  
  <p>For server side, running on Tomcat 8 and JDK8.</p>
  
  <p><strong>EDIT</strong> I add -Djavax.net.debug=ssl,handshake and find following:</p>
  
  <pre><code>*** main, WRITE: TLSv1 Handshake, length = 177 main, WRITE: SSLv2 client hello message, length = 173
  main, received EOFException: error main, handling exception: javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
  main, SEND TLSv1 ALERT: fatal, description = handshake_failure
  main, WRITE: TLSv1 Alert, length = 2 main, called closeSocket()
  main, called close() main, called closeInternal(true)
  </code></pre>