public static THttpClient getThriftHttpsClient(String httpsUrl, String trustStorePath,
      String trustStorePasswd, String trustStoreAlgorithm, String trustStoreType,
      HttpClientBuilder underlyingHttpClientBuilder) throws TTransportException, IOException,
      KeyStoreException, NoSuchAlgorithmException, CertificateException,
      KeyManagementException {
    Preconditions.checkNotNull(underlyingHttpClientBuilder, "httpClientBuilder should not be null");
    if (trustStoreType == null || trustStoreType.isEmpty()) {
      trustStoreType = KeyStore.getDefaultType();
    }
    KeyStore sslTrustStore = KeyStore.getInstance(trustStoreType);
    try (FileInputStream fis = new FileInputStream(trustStorePath)) {
      sslTrustStore.load(fis, trustStorePasswd.toCharArray());
    }

    SSLContext sslContext =
        SSLContexts.custom().setTrustManagerFactoryAlgorithm(trustStoreAlgorithm).
            loadTrustMaterial(sslTrustStore, null).build();
    SSLConnectionSocketFactory socketFactory =
        new SSLConnectionSocketFactory(sslContext, new DefaultHostnameVerifier(null));
    final Registry<ConnectionSocketFactory> registry =
        RegistryBuilder.<ConnectionSocketFactory> create().register("https", socketFactory)
            .build();
    underlyingHttpClientBuilder.setConnectionManager(new BasicHttpClientConnectionManager(registry));
    return new THttpClient(httpsUrl, underlyingHttpClientBuilder.build());
  }
@return the user name set in hadoop.job.ugi param or the current user from System
@throws IOException if underlying Hadoop call throws LoginException
standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/SecurityUtils.java