user3437564 user3437564 - 2 years ago 170
Android Question

How to add .p12 certificate to android device

I have trouble with loading .p12 certificate to my android.project. Here is chank of source code:

char[] password = "<my pass>".toCharArray();
FileInputStream fIn = new FileInputStream("<name of cert>");
KeyStore keystore = KeyStore.getInstance("PKCS12");
keystore.load(fIn, password);

On line 2 occured error openning cert file.

Can anybody help me. How can i properly to add cert file to my android program?

Answer Source

Try this

File cert = new File("mnt/sdcard/" + filename + ".p12");
InputStream inputStreamFromDownload = null;

keyStore = KeyStore.getInstance("PKCS12");
inputStreamFromDownload = new BufferedInputStream(new FileInputStream(cert));

Log.i("Certificate", inputStreamFromDownload.available() + "");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download