Search in sources :

Example 1 with TrustEverythingSSLTrustManager

use of io.fabric8.utils.ssl.TrustEverythingSSLTrustManager in project fabric8 by fabric8io.

the class WebClients method disableSslChecks.

public static void disableSslChecks(WebClient webClient) {
    HTTPConduit conduit = WebClient.getConfig(webClient).getHttpConduit();
    TLSClientParameters params = conduit.getTlsClientParameters();
    if (params == null) {
        params = new TLSClientParameters();
        conduit.setTlsClientParameters(params);
    }
    params.setTrustManagers(new TrustManager[] { new TrustEverythingSSLTrustManager() });
    params.setDisableCNCheck(true);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) TLSClientParameters(org.apache.cxf.configuration.jsse.TLSClientParameters) TrustEverythingSSLTrustManager(io.fabric8.utils.ssl.TrustEverythingSSLTrustManager)

Example 2 with TrustEverythingSSLTrustManager

use of io.fabric8.utils.ssl.TrustEverythingSSLTrustManager in project fabric8 by fabric8io.

the class GitUtils method disableSslCertificateChecks.

public static void disableSslCertificateChecks() {
    LOG.info("Trusting all SSL certificates");
    try {
        SSLContext context = SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[] { new TrustEverythingSSLTrustManager() }, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory());
        // bypass host name check, too.
        HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {

            public boolean verify(String s, SSLSession sslSession) {
                return true;
            }
        });
    } catch (NoSuchAlgorithmException e) {
        LOG.warn("Failed to bypass certificate check", e);
    } catch (KeyManagementException e) {
        LOG.warn("Failed to bypass certificate check", e);
    }
}
Also used : SSLSession(javax.net.ssl.SSLSession) TrustEverythingSSLTrustManager(io.fabric8.utils.ssl.TrustEverythingSSLTrustManager) SSLContext(javax.net.ssl.SSLContext) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyManagementException(java.security.KeyManagementException) HostnameVerifier(javax.net.ssl.HostnameVerifier)

Aggregations

TrustEverythingSSLTrustManager (io.fabric8.utils.ssl.TrustEverythingSSLTrustManager)2 KeyManagementException (java.security.KeyManagementException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 HostnameVerifier (javax.net.ssl.HostnameVerifier)1 SSLContext (javax.net.ssl.SSLContext)1 SSLSession (javax.net.ssl.SSLSession)1 TLSClientParameters (org.apache.cxf.configuration.jsse.TLSClientParameters)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1