title: Migration from httpclient4 to httpclient5
body: <p>in our project we switched from apache httpclient 4 to httpclient 5 now we have a ssl problem in one module. The code in httpclient 4 was</p>
  <pre class="lang-java prettyprint-override"><code>private void buildHttpClient() throws MalformedURLException {
    try {
        URL aURL = new URL(BASE_URL);
      String host = aURL.getAuthority();
      SSLSocketFactory socketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
        HostnameVerifier defaultHostnameVerifier = SSLConnectionSocketFactory.getDefaultHostnameVerifier();
        SSLConnectionSocketFactory systemSocketFactory = new SSLConnectionSocketFactory(socketFactory, defaultHostnameVerifier);
      CredentialsProvider provider = new BasicCredentialsProvider();
      provider.setCredentials(
          new AuthScope(new HttpHost(host)), 
          new UsernamePasswordCredentials(USER, PASSWORD));
      httpclient = HttpClients.custom()
          .setDefaultCredentialsProvider(provider)
          .setSSLSocketFactory(systemSocketFactory)
          .build();
    } catch (MalformedURLException e) {
      throw new MalformedURLException(BASE_URL);
    }
  }
  </code></pre>
  <p>the new code is</p>
  <pre class="lang-java prettyprint-override"><code>private void buildClient() throws MalformedURLException {
  
    URL aURL = new URL(BASE_URL);
    String host = aURL.getAuthority();
  
        final BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
        credsProvider.setCredentials(
                new AuthScope(host, 443),
                new UsernamePasswordCredentials(USER, PASSWORD.toCharArray()));
  
        SSLContext ctx = SSLContexts.createDefault();
        final SSLConnectionSocketFactory sslSocketFactory = SSLConnectionSocketFactoryBuilder.create()
                .setSslContext(ctx)
                .build();
        final HttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create()
                .setSSLSocketFactory(sslSocketFactory)
                .build();
        
    httpclient = HttpClients.custom()
          .setConnectionManager(cm)
          .setDefaultCredentialsProvider(credsProvider)
          .build();
  }
  </code></pre>
  <p>httpclient is <code>CloseableHttpClient</code> in both cases. Testin locally never got a problem but testing on the customer server shows now PKIX path building failed: com.ibm.security.cert.IBMCertPathBuilderException: unable to find valid certification path to requested target
  When i roll back to an old deployment it works on the server but the new one doesn't work. The keystore deployed by the customer should be correct and I don't want to use an own keystore.</p>
  <p>Can somebody describe where I should look, or what is the problem with the ssl?</p>