title: PoolingHttpClientConnectionManager: How to do Https requests?
body: <p>I'm currently trying to do multiple <code>HttpGet</code> requests at the same time with <code>CloseableHttpClient</code>.<br>
  I googled on how to do that and the answer was to use a <code>PoolingHttpClientConnectionManager</code>.<br></p>
  
  <p>At this point I got this:</p>
  
  <pre><code>PoolingHttpClientConnectionManager cManager = new PoolingHttpClientConnectionManager();
  CloseableHttpClient httpClient = HttpClients.custom()
      .setConnectionManager(cManager)
      .build();
  </code></pre>
  
  <p>Then I tried a <code>HttpGet</code> request to <code>http://www.google.com</code> and everything worked fine.<br></p>
  
  <p>Then I created a truststore via cmd and imported the certificate of the targeted website, setup a <code>SSLConnectionSocketFactory</code> with my truststore and set the <code>SSLSocketFactory</code> of <code>httpClient</code>:</p>
  
  <pre><code>KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
  FileInputStream inputStream = new FileInputStream(new File("myTrustStore.truststore"));
  trustStore.load(inputStream, "nopassword".toCharArray());
  inputStream.close();
  
  SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(trustStore).build();
  SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext,
      SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
  
  PoolingHttpClientConnectionManager cManager = new PoolingHttpClientConnectionManager();
  CloseableHttpClient httpClient = HttpClients.custom()
      .setSSLSocketFactory(sslsf)
      .setConnectionManager(cManager)
      .build();
  </code></pre>
  
  <p>If I try to execute a Https <code>HttpGet</code> then I get a <code>PKIX path building failed</code> exception.<br>
  If I do the same without <code>.setConnectionManager(cManager)</code> everything works fine.</p>
  
  <p>Can anyone of you tell me how I can get this to work? (Don't worry, I don't create any ddos tool)</p>
  
  <p>Thanks in advance!</p>
  
  <p>P.S.: I'm using HttpComponents 4.3.1</p>