Search in sources :

Example 1 with RestClientException

use of io.syndesis.qe.exceptions.RestClientException in project syndesis-qe by syndesisio.

the class RestUtils method createAllTrustingClient.

// Required in order to skip certificate validation
private static HttpClient createAllTrustingClient() throws RestClientException {
    HttpClient httpclient = null;
    try {
        final SSLContextBuilder builder = new SSLContextBuilder();
        builder.loadTrustMaterial((TrustStrategy) (X509Certificate[] chain, String authType) -> true);
        final SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build());
        httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).setMaxConnTotal(1000).setMaxConnPerRoute(1000).build();
    } catch (NoSuchAlgorithmException | KeyStoreException | KeyManagementException e) {
        throw new RestClientException("Cannot create all SSL certificates trusting client", e);
    }
    return httpclient;
}
Also used : HttpClient(org.apache.http.client.HttpClient) RestClientException(io.syndesis.qe.exceptions.RestClientException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStoreException(java.security.KeyStoreException) SSLContextBuilder(org.apache.http.ssl.SSLContextBuilder) SSLConnectionSocketFactory(org.apache.http.conn.ssl.SSLConnectionSocketFactory) X509Certificate(java.security.cert.X509Certificate) KeyManagementException(java.security.KeyManagementException)

Aggregations

RestClientException (io.syndesis.qe.exceptions.RestClientException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 X509Certificate (java.security.cert.X509Certificate)1 HttpClient (org.apache.http.client.HttpClient)1 SSLConnectionSocketFactory (org.apache.http.conn.ssl.SSLConnectionSocketFactory)1 SSLContextBuilder (org.apache.http.ssl.SSLContextBuilder)1