Source:
<code>private HttpURLConnection createURLConnection() throws IOException, NoSuchAlgorithmException, CertificateException, KeyStoreException, KeyManagementException { logger.debug( String.format( "createURLConnection: servletURL=%s, sslIgnoreCertErrors=%s, sslIgnoreHostVerification=%s, trustStorePath=%s", servletURL, sslIgnoreCertErrors, sslIgnoreHostVerification, trustStorePath ) ); URL url = new URL(servletURL); HttpURLConnection servletConnection = (HttpURLConnection) url.openConnection(); if ("https".equals(url.getProtocol())) { TrustManager[] trustManagers; if (sslIgnoreCertErrors) { trustManagers = new TrustManager[] { new X509TrustManager() { @Override public void checkClientTrusted(X509Certificate[] certs, String authType) throws CertificateException @Override public void checkServerTrusted(X509Certificate[] certs, String authType) throws CertificateException @Override public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[] {}; } <START> } <END> }; } else { if (trustStorePassword == null || trustStorePath == null) { throw new RuntimeException("The Supplied URL is secured, however no trust store path or password were supplied."); } KeyStore trustStore = KeyStore.getInstance(trustStoreType); trustStore.load(new FileInputStream(trustStorePath), trustStorePassword.toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(trustStore); trustManagers = trustManagerFactory.getTrustManagers(); } SSLContext ctx = SSLContext.getInstance(sslProtocol); ctx.init(null, trustManagers, null); HttpsURLConnection httpsConnection = (HttpsURLConnection)servletConnection; httpsConnection.setSSLSocketFactory(ctx.getSocketFactory()); if (sslIgnoreHostVerification) { httpsConnection.setHostnameVerifier( new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } } ); } } servletConnection.setRequestMethod("POST"); servletConnection.setDoOutput(true); servletConnection.setDoInput(true); servletConnection.setReadTimeout(10000); servletConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); return servletConnection; }</code><technical_language>is in external method? code a bit more simple, imo</technical_language>

Target:
private HttpURLConnection createURLConnection() throws MalformedURLException, IOException, ProtocolException { logger.debug( String.format( "createURLConnection: servletURL=%s, sslIgnoreCertErrors=%s, sslIgnoreHostVerification=%s, trustStorePath=%s", servletURL, sslIgnoreCertErrors, sslIgnoreHostVerification, trustStorePath ) ); URL url = new URL(servletURL); HttpURLConnection servletConnection = (HttpURLConnection) url.openConnection(); if ("https".equals(url.getProtocol())) { HttpsURLConnection httpsConnection = (HttpsURLConnection)servletConnection; httpsConnection.setSSLSocketFactory(sslctx.getSocketFactory()); if (sslIgnoreHostVerification) { httpsConnection.setHostnameVerifier( new HostnameVerifier() { @Override public boolean verify(String hostname, SSLSession session) { return true; } } ); } } servletConnection.setRequestMethod("POST"); servletConnection.setDoOutput(true); servletConnection.setDoInput(true); servletConnection.setReadTimeout(10000); servletConnection.setRequestProperty("Content-Type","application/x-www-form-urlencoded"); return servletConnection; }