try {
FileInputStream fis = new FileInputStream("mvsr.pfx");
DataInputStream dis = new DataInputStream(fis );
PKCS12 pk = new PKCS12( fis );
char[] password = "sailsail".toCharArray();
pk.decrypt(password);
System.out.println(pk.getKeyBag().getPrivateKey());
PrivateKey private_key = pk.getKeyBag().getPrivateKey();
System.out.println(pk);
iaik.pkcs.pkcs12.CertificateBag[] bg = pk.getCertificateBags();
System.out.println("------------");
System.out.println(bg[0]);
System.out.println("---------------" + bg.length);
System.out.println(bg[0].getCertificate());
X509Certificate[] ctf = new X509Certificate[1];
ctf[0] = (X509Certificate)bg[0].getCertificate();
((SSLClientContext)context).addClientCredentials(ctf, private_key);
}catch(Exception e ) { e.printStackTrace(); }
HttpsURLConnection.setDefaultSSLContext(context);