title: SSL handshake failure error despite importing certificates in java cacerts
body: <p>I'm trying to GET some data using a REST api. I am using apache's http client for it.However, whenever I try to connect it shows me an 'SSL handshake failure'  </p>
  
  <p>What I did was:
  1. From chrome, download the certificates for the website. It has 3 certificates in the following hierarchy</p>
  
  <pre><code>-- Cert 3
    --Cert 2
      -- Cert 1 
  </code></pre>
  
  <ol start="2">
  <li>Next i ran this command inside my securities folder under Java JRE</li>
  </ol>
  
  <p><code>keytool -keystore cacerts -importcert -alias para1 -file Cert1.cer</code><br>
  <code>keytool -keystore cacerts -importcert -alias para2 -file Cert2.cer</code><br>
  <code>keytool -keystore cacerts -importcert -alias para3 -file Cert3.cer</code></p>
  
  <p>This step was successful</p>
  
  <ol start="3">
  <li><p>I closed and reopened Eclipse, however the error doesn't go away.</p>
  
  <ul>
  <li>Is there some refresh function in eclipse that I am missing that will make use of the updated keystore?</li>
  <li>Or am i supposed to import the whole chain and link them somehow instead of importing each of them individually.</li>
  </ul></li>
  </ol>
  
  <p>Here is the stack trace:</p>
  
  <pre><code>javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
      at sun.security.ssl.Alerts.getSSLException(Unknown Source)
      at sun.security.ssl.Alerts.getSSLException(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.recvAlert(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
      at sun.security.ssl.AppOutputStream.write(Unknown Source)
      at java.io.BufferedOutputStream.flushBuffer(Unknown Source)
      at java.io.BufferedOutputStream.flush(Unknown Source)
      at org.apache.commons.httpclient.HttpConnection.flushRequestOutputStream(HttpConnection.java:828)
      at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2116)
      at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096)
      at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398)
      at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
      at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
      at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
      at Upload.get(Get.java:124)
      at Upload.main(Get.java:63)
  </code></pre>