@ Deprecated public static void removeSshCertificateChecks ( final HttpClient httpClient ) throws IllegalStateException { try { // prepare a SSL context which doesn't validate certificates final SSLContext sslContext = SSLContext . getInstance ( "SSL" ) ; final TrustManager trustManager = new NaiveTrustManager ( ) ; sslContext . init ( null , new TrustManager [ ] { trustManager } , new SecureRandom ( ) ) ; final org . apache . http . conn . ssl . SSLSocketFactory schemeSocketFactory = new org . apache . http . conn . ssl . SSLSocketFactory ( sslContext ) ; final org . apache . http . conn . scheme . Scheme sslScheme = new org . apache . http . conn . scheme . Scheme ( "https" , 443 , schemeSocketFactory ) ; // try again with a new registry final org . apache . http . conn . scheme . SchemeRegistry registry = httpClient . getConnectionManager ( ) . getSchemeRegistry ( ) ; registry . register ( sslScheme ) ; } catch ( final Exception e ) { throw new IllegalStateException ( e ) ; } }
Removes the certificate checks of HTTPS traffic on a HTTP client . Use with caution!