title: How to use Apache Httpclient with Jersey 2.3 client
body: <p>I would like to use an Apache connector with Jersey 2.3 client for HTTPS connections.</p>
  
  <p>I tried the following:</p>
  
  <pre><code>ClientConfig clientConfig = new ClientConfig();
  clientConfig.property(ApacheClientProperties.CONNECTION_MANAGER, new PoolingClientConnectionManager());
  
  ApacheConnector connector = new ApacheConnector(clientConfig);  
  clientConfig.connector(connector);  
  
  Client client = ClientBuilder.newBuilder()
      .withConfig(clientConfig)
      .sslContext(sslContext)
      .hostnameVerifier(getHostnameVerifier())
      .build();
  </code></pre>
  
  <p>However, it seems the sslContext is ignored as the certificate of the server is rejected as untrusted (sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target)</p>
  
  <p>If I remove the ".withConfig(clientConfig)" part, the SSL connection works fine, but evidently without the Apache connector. Is there a way to use my own ClientConfig with the Apache connector as well as my own SSLContext?</p>