Search in sources :

Example 6 with SSLIOSessionStrategy

use of org.apache.http.nio.conn.ssl.SSLIOSessionStrategy in project drill by apache.

the class WebUtils method createHttpClient.

private static CloseableHttpAsyncClient createHttpClient(DrillConfig drillConfig) throws Exception {
    HttpAsyncClientBuilder clientBuilder = HttpAsyncClients.custom();
    if (drillConfig.getBoolean(ExecConstants.HTTP_ENABLE_SSL)) {
        SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(new TrustSelfSignedStrategy()).build();
        SSLIOSessionStrategy sessionStrategy = new SSLIOSessionStrategy(sslContext, new String[] { drillConfig.getString(ExecConstants.SSL_PROTOCOL) }, null, SSLIOSessionStrategy.getDefaultHostnameVerifier());
        clientBuilder.setSSLStrategy(sessionStrategy);
    }
    RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(drillConfig.getInt(ExecConstants.HTTP_CLIENT_TIMEOUT)).build();
    clientBuilder.setDefaultRequestConfig(requestConfig);
    return clientBuilder.build();
}
Also used : RequestConfig(org.apache.http.client.config.RequestConfig) SSLIOSessionStrategy(org.apache.http.nio.conn.ssl.SSLIOSessionStrategy) SSLContext(javax.net.ssl.SSLContext) TrustSelfSignedStrategy(org.apache.http.conn.ssl.TrustSelfSignedStrategy) HttpAsyncClientBuilder(org.apache.http.impl.nio.client.HttpAsyncClientBuilder)

Aggregations

SSLContext (javax.net.ssl.SSLContext)6 SSLIOSessionStrategy (org.apache.http.nio.conn.ssl.SSLIOSessionStrategy)6 SchemeIOSessionStrategy (org.apache.http.nio.conn.SchemeIOSessionStrategy)4 KeyManagementException (java.security.KeyManagementException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 RequestConfig (org.apache.http.client.config.RequestConfig)3 PoolingNHttpClientConnectionManager (org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager)3 DefaultConnectingIOReactor (org.apache.http.impl.nio.reactor.DefaultConnectingIOReactor)3 ConnectingIOReactor (org.apache.http.nio.reactor.ConnectingIOReactor)3 KeyStoreException (java.security.KeyStoreException)2 CertificateException (java.security.cert.CertificateException)2 HostnameVerifier (javax.net.ssl.HostnameVerifier)2 ConnectionConfig (org.apache.http.config.ConnectionConfig)2 DefaultHostnameVerifier (org.apache.http.conn.ssl.DefaultHostnameVerifier)2 BasicCookieStore (org.apache.http.impl.client.BasicCookieStore)2 IOReactorConfig (org.apache.http.impl.nio.reactor.IOReactorConfig)2 BasicHeader (org.apache.http.message.BasicHeader)2 JestClientFactory (io.searchbox.client.JestClientFactory)1 HttpClientConfig (io.searchbox.client.config.HttpClientConfig)1 Bulk (io.searchbox.core.Bulk)1