ssl connection
public URLConnection createURLConnection(String ip_pageUrl){
try{
InputStream in = new FileInputStream(this.cacertsPath);
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(in, null);
in.close();
SSLContext sslContext = SSLContext.getInstance(this.sslProtocol);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ks);
X509TrustManager defaultTrustManager = (X509TrustManager)tmf.getTrustManagers()[0];
sslContext.init(null, new TrustManager[] { defaultTrustManager }, null);
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
URL url = new URL(ip_pageUrl);
URLConnection con = url.openConnection(); // from secure site
if (con instanceof javax.net.ssl.HttpsURLConnection) {
((javax.net.ssl.HttpsURLConnection) con).setSSLSocketFactory(sslSocketFactory);
}
return con;
}catch(Exception e){
logger.error("Post Error : ", e);
}
return null;
}