Source:
private HttpURLConnection createURLConnection() throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, KeyManagementException { boolean secured = servletURL.startsWith("https"); URL url = new URL(servletURL); HttpURLConnection servletConnection; if (secured) { if (trustStorePassword == null || trustStorePath == null) { logger.error("The Supplied URL is secured, however no trust store path or password were supplied."); return null; } HttpsURLConnection securedConnection = (HttpsURLConnection) url.openConnection(); KeyStore trustStore = KeyStore.getInstance(trustStoreType); trustStore.load(new FileInputStream(trustStorePath), trustStorePassword.toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustStore); SSLContext ctx = SSLContext.getInstance(sslProtocol); if (sslIgnoreCertErrors) { logger.debug("sslIgnoreCertErrors mode"); ctx.init(null, new TrustManager[] { new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } @Override public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } } }, null); } else { ctx.init(null, trustManagerFactory.getTrustManagers(), null); } securedConnection.setSSLSocketFactory(ctx.getSocketFactory()); if (sslIgnoreHostVerification) { logger.debug("sslIgnoreHostVerification mode"); securedConnection.setHostnameVerifier(IgnoredHostnameVerifier); } servletConnection = securedConnection; } else { servletConnection = (HttpURLConnection) url.openConnection(); } servletConnection.setRequestMethod("POST"); servletConnection.setDoOutput(true); servletConnection.setDoInput(true); servletConnection.setReadTimeout(10000); servletConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); return servletConnection; }

Target:
private HttpURLConnection createURLConnection() throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, KeyManagementException { boolean secured = servletURL.startsWith("https"); URL url = new URL(servletURL); HttpURLConnection servletConnection; if (secured) { if (trustStorePassword == null || trustStorePath == null) { logger.error("The Supplied URL is secured, however no trust store path or password were supplied."); return null; } HttpsURLConnection securedConnection = (HttpsURLConnection) url.openConnection(); KeyStore trustStore = KeyStore.getInstance(trustStoreType); trustStore.load(new FileInputStream(trustStorePath), trustStorePassword.toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustStore); SSLContext ctx = SSLContext.getInstance(sslProtocol); initSslcontext(ctx, trustManagerFactory); securedConnection.setSSLSocketFactory(ctx.getSocketFactory()); if (sslIgnoreHostVerification) { logger.debug("sslIgnoreHostVerification mode"); securedConnection.setHostnameVerifier(IgnoredHostnameVerifier); } servletConnection = securedConnection; } else { servletConnection = (HttpURLConnection) url.openConnection(); } servletConnection.setRequestMethod("POST"); servletConnection.setDoOutput(true); servletConnection.setDoInput(true); servletConnection.setReadTimeout(10000); servletConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); return servletConnection; }