title: HTTPClient-1.4.2: Explanation needed for Custom SSL Context Example
body: <p>This is the example for Custom SSL Context from HttpClient-4.x documentation: <a href="http://hc.apache.org/httpcomponents-client-ga/examples.html" rel="nofollow">http://hc.apache.org/httpcomponents-client-ga/examples.html</a></p>
  
  <p>Note: removing comments for brevity.</p>
  
  <pre><code>package org.apache.http.examples.client;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.security.KeyStore;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.conn.scheme.Scheme;
  import org.apache.http.conn.ssl.SSLSocketFactory;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.util.EntityUtils;
  
  /**
   * This example demonstrates how to create secure connections with a custom SSL
   * context.
   */
  public class ClientCustomSSL {
  
      public final static void main(String[] args) throws Exception {
          DefaultHttpClient httpclient = new DefaultHttpClient();
          try {
              KeyStore trustStore  = KeyStore.getInstance(KeyStore.getDefaultType());
              FileInputStream instream = new FileInputStream(new File("my.keystore"));
              try {
                  trustStore.load(instream, "nopassword".toCharArray());
              } finally {
                  try { instream.close(); } catch (Exception ignore) {}
              }
  
              SSLSocketFactory socketFactory = new SSLSocketFactory(trustStore);
              Scheme sch = new Scheme("https", 443, socketFactory);
              httpclient.getConnectionManager().getSchemeRegistry().register(sch);
  
              HttpGet httpget = new HttpGet("https://localhost/");
  
              System.out.println("executing request" + httpget.getRequestLine());
  
              HttpResponse response = httpclient.execute(httpget);
              HttpEntity entity = response.getEntity();
  
              System.out.println("----------------------------------------");
              System.out.println(response.getStatusLine());
              if (entity != null) {
                  System.out.println("Response content length: " + entity.getContentLength());
              }
              EntityUtils.consume(entity);
  
          } finally {
              // When HttpClient instance is no longer needed,
              // shut down the connection manager to ensure
              // immediate deallocation of all system resources
              httpclient.getConnectionManager().shutdown();
          }
      }
  
  }
  </code></pre>
  
  <p>I assume my.keystore is the location of the trustStore where CA root certificate is imported to: /Library/Java/Home/lib/security/cacerts and the default password for this truststore is "changeit". </p>
  
  <p>My question is: where should I put my client certificates in order to communicate with server. I've both ways SSL setup.</p>
  
  <p>Above example code doesn't give any hint about client certificates: pem/p12 and key files.</p>
  
  <p>Any ideas/thoughts would be appreciated !!!</p>
  
  <p>-Bianca</p>