public String SELFCERTPATH = "D://work/software/B4j/20180314Test/cert/outgoing.CertwithKey.pkcs12";
public String SELFCERTPWD = "IoM@1234";
public String TRUSTCAPATH = "D://work/software/B4j/20180314Test/cert/ca.jks";
public String TRUSTCAPWD = "Huawei@123";
public void initSSLConfigForTwoWay() throws Exception {
KeyStore selfCert = KeyStore.getInstance("pkcs12");
selfCert.load(new FileInputStream(SELFCERTPATH), SELFCERTPWD.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance("sunx509");
kmf.init(selfCert, SELFCERTPWD.toCharArray());
KeyStore caCert = KeyStore.getInstance("jks");
caCert.load(new FileInputStream(TRUSTCAPATH), TRUSTCAPWD.toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance("sunx509");
tmf.init(caCert);
SSLContext sc = SSLContext.getInstance("TLS");
sc.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
SSLSocketFactory ssf = new SSLSocketFactory(sc);
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = this.getConnectionManager();
SchemeRegistry sr = ccm.getSchemeRegistry();
sr.register(new Scheme("https", ssf, 8743));
}