title: 'peer not authenticated' SSL certificate error usng DefaultHttpClient
body: <p>I have an application jar from which I m calling an <strong>HTTPS url using DefaultHTTPClient class</strong> object but its giving <strong>peer not authenticate exception</strong>, so I want to sign jar using keystore.</p>
  
  <p>I have .cer file which has public key and I can able to import into keystore but when I use jarsigner tool it says certificate chain not found.you must have private key and associate public key.</p>
  
  <p>I have .pfx file also which is suppose to an private key but I don't know how to import it.can any one able to tell me the steps how to import .pfx file and use in jarsigner.</p>
  
  <p>Correct me if I m wrong somewhere..</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>As per @Duncan I am able to import .cer file in JVM by referring <a href="http://blog.nerdability.com/2013/01/tech-how-to-fix-sslpeerunverifiedexcept.html" rel="noreferrer">This Link.</a>. I used bellowed command to import .cer into cacerts</p>
  
  <p><code>c:\Program Files\Java\jre7\bin&gt;keytool -importcert -alias esbcert -file "e:\Desktop\esbcert\esb.cer" -keystore "c:\Program Files\Java\jre7\lib\security\cacerts"
   -storepass changeit</code></p>
  
  <p>After this I entered 'y' to trust the certificate</p>
  
  <p><code>Trust this certificate? [no]:  y
  Certificate was added to keystore</code></p>
  
  <p>After that I Run my application but it still gives me <code>javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated</code></p>
  
  <p>Stack is as follows :</p>
  
  <pre><code>javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
          at sun.security.ssl.SSLSessionImpl.getPeerCertificates(Unknown Source)
          at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.jav
  a:126)
          at org.apache.http.conn.ssl.SSLSocketFactory.connectSocket(SSLSocketFact
  ory.java:572)
          at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnect
  ion(DefaultClientConnectionOperator.java:180)
          at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedCli
  entConnectionImpl.java:294)
          at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(Default
  RequestDirector.java:645)
          at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultReq
  uestDirector.java:480)
          at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpCl
  ient.java:906)
          at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpCl
  ient.java:805)
          at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpCl
  ient.java:784)
          at testhttps.TestHTTPS.testWithMKCLHTTPClient(TestHTTPS.java:95)
          at testhttps.TestHTTPS.main(TestHTTPS.java:49)
  </code></pre>
  
  <p>My Code is :</p>
  
  <pre><code>String url = "https://domain.org/webapp/transformer/doTransformer/doReg";
  try {
  
  
      HttpPost postRequest = new HttpPost(url);       
      HttpResponse httpResponse = null;
  
      DefaultHttpClient httpClient = new DefaultHttpClient();     
      httpResponse = httpClient.execute(postRequest);             
  } catch (Exception e) {         
      e.printStackTrace();
  }
  </code></pre>