private CloseableHttpClient buildHttpClient() throws AmbariException {
    HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
    if (skipSslCertificateCheck) {
      final SSLContext sslContext;
      try {
        sslContext = new SSLContextBuilder()
          .loadTrustMaterial(null, (x509CertChain, authType) -> true)
          .build();
      } catch (NoSuchAlgorithmException | KeyManagementException | KeyStoreException e) {
        throw new AmbariException("Cannot build null truststore.", e);
      }

      httpClientBuilder.setSSLContext(sslContext)
      .setConnectionManager(
        new PoolingHttpClientConnectionManager(
          RegistryBuilder.<ConnectionSocketFactory>create()
            .register("http", PlainConnectionSocketFactory.INSTANCE)
            .register("https", new SSLConnectionSocketFactory(sslContext,
                                                              NoopHostnameVerifier.INSTANCE))
            .build()
        ));
    }
    return httpClientBuilder.build();
  }
Class that provides support to work with URLs behind redirects.
ambari-server/src/main/java/org/apache/ambari/server/controller/internal/URLRedirectProvider.java