title: SSL Handshake fatal error after Client Hello
body: <p>I am trying to make an https call to a server signed by an internal CA. I couldn't get it working in spite of adding the root certificates in the truststore so I've set the trustManager to trust all certificates and disabled hostname verification for now.<br>
  <code>curl --insecure</code> call works.<br>
  With <code>-Djavax.net.debug=all</code>, the handshake fails after client hello</p>
  
  <blockquote>
    <p>*** ClientHello, TLSv1   ...   ...    main, READ: TLSv1 Alert, length = 2   main, RECV TLSv1 ALERT:  fatal, handshake_failure   main, called closeSocket()   main, handling exception:
    javax.net.ssl.SSLHandshakeException: Received fatal alert:
    handshake_failure   main, called close()   main, called
    closeInternal(true)</p>
  </blockquote>
  
  <p>The stack trace is:</p>
  
  <blockquote>
    <p>javax.net.ssl.SSLHandshakeException: Received fatal alert:
    handshake_failure     at
    sun.security.ssl.Alerts.getSSLException(Alerts.java:192)  at
    sun.security.ssl.Alerts.getSSLException(Alerts.java:154)  at
    sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:1959)     at
    sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1077)    at
    sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1312)
      at
    sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
      at
    sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1323)</p>
  </blockquote>
  
  <p>I am getting the SSL Context using </p>
  
  <pre><code>SSLContext sslContext = SSLContext.getInstance("TLS");
  </code></pre>
  
  <p>Any help would be highly appreciated.</p>
  
  <p>PS: I am using <strong>java7</strong></p>