/** * Configures the HttpClient with an SSL TrustManager that will accept any SSL server certificate. * The server SSL certificate will not be verified. This method creates a new Scheme for "https" * that is setup for an SSL context to uses an DoNotVerifySSLCertificateTrustManager instance. * This scheme will be registered with the HttpClient using the * getConnectionManager().getSchemeRegistry().register(https) method. * * @param client The HttpClient to configure. */ public static void configureWithNoSslCertificateVerification(HttpClient client) throws NoSuchAlgorithmException, KeyManagementException { // // create a new https scheme with no SSL verification // Scheme httpsScheme = SchemeFactory.createDoNotVerifyHttpsScheme(); // // register this new scheme on the https client // client.getConnectionManager().getSchemeRegistry().register(httpsScheme); }
/** * Adding support for SSL mutual authentication using specified keystore/truststore. Specifying * keystore/truststore is optional. If unspecified, a normal SSL scheme is created. */ public static void configureWithSslKeystoreTruststore( HttpClient client, File keystoreFile, String keystorePassword, File truststoreFile, String truststorePassword) throws CertificateException, FileNotFoundException, IOException, KeyStoreException, KeyManagementException, NoSuchAlgorithmException, UnrecoverableKeyException { // // create a new https scheme with no SSL verification // Scheme httpsScheme = SchemeFactory.createHttpsScheme( keystoreFile, keystorePassword, truststoreFile, truststorePassword); // // register this new scheme on the https client // client.getConnectionManager().getSchemeRegistry().register(httpsScheme); }