Import .p12-file into AndroidKeyStore

后端 未结 2 1057
心在旅途
心在旅途 2021-01-01 06:32

The user has saved a .p12-file (e.g. his S/MIME certificate) on SD-Card. I want to load this certificate (or the extracted private and public key) into the AndroidKeyStore.

2条回答
  •  滥情空心
    2021-01-01 06:52

    If you want to install your certificate into the android KeyChain you can use your P12 to install it directly like in the next method:

        InputStream is = new ByteArrayInputStream(pkcs12);
        BufferedInputStream bis = new BufferedInputStream(is);
        byte[] keychainP12 = new byte[bis.available()];
        bis.read(keychainP12);
        Intent installIntent = KeyChain.createInstallIntent();
        installIntent.putExtra(KeyChain.EXTRA_PKCS12, keychainP12);
        context.startActivity(installIntent);
    

提交回复
热议问题