throws IOException,
UnknownHostException,
ConnectTimeoutException {
SSLContext context;
SSLSocketFactory factory = null;
SSLSocket socket = null;
try {
KeyManagerFactory kmf;
KeyStore ks;
char[] passphrase = keyPass.toCharArray();
context = SSLContext.getInstance(protocol);
kmf = KeyManagerFactory.getInstance(kmfFactory);
ks = KeyStore.getInstance(keyStoreType);
ks.load(new FileInputStream(keyStore), passphrase);
TrustManager tm = (this.tm != null) ? this.tm : new X509TrustManager() {
public void checkClientTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {}
public void checkServerTrusted(X509Certificate[] arg0, String arg1)
throws CertificateException {}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
kmf.init(ks, passphrase);
context.init(kmf.getKeyManagers(), new TrustManager[] {tm}, null);
factory = context.getSocketFactory();
socket = (SSLSocket) factory.createSocket(host, port);
return socket;
} catch (Exception e) {
e.printStackTrace();
}
return null;