Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Export certificate in windows store to a p12 file using Java

I will need to export a certificate in windows store to a p12 file. Similar to what you can do from firefox/IE browser but in JAVA. The only way I am able to do it currently is doing a C# with double Cpp wrappers or MCPP with wrapper using JNI which is not really useful. I have tried using SUNMSCAPI but I was not able to.. Any inputs appreciated.. Thank you..

If the above is certainly not possible, can a keystore be created with these certs?

like image 688
luckylak Avatar asked Feb 08 '11 22:02

luckylak


People also ask

How do I save as p12?

In the Keychain Access window, under Keychains, click login, under Category, click Certificates, and then, select your certificate In the Keychain Access toolbar, click File > Export Items. In the “Export” window, do the following: In the File Format drop-down list select Personal information Exchange (. p12).


1 Answers

You can use the Java standard keystore API, with Bouncy Castle. You can load the keystore called Windows-MY, that contains all the certificates stored in the Windows keystore.

KeyStore.getInstance("Windows-MY");

The reference to the Windows keystore provides method to extract certificates, via the KeyStore.getCertificate(String alias) method.

Once you retrieved the certificate, export it to a PKCS12 file.

like image 54
Vivien Barousse Avatar answered Oct 11 '22 14:10

Vivien Barousse