How do you add a .p12 certificate to an Android device?

后端 未结 2 1250
独厮守ぢ
独厮守ぢ 2021-01-06 22:59

I\'m having trouble loading a .p12 certificate to my Android project. Here is a chunk of source code:

char[] password = "".toCharArra         


        
相关标签:
2条回答
  • 2021-01-06 23:51

    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() + "");
    
    0 讨论(0)
  • 2021-01-07 00:04

    ...

    In Android, I see people programmatically install keystore in the following way (The code is from Android developer blog):

    byte[] keystore = . . (read from a PKCS#12 keystore)
    
    Intent installIntent = KeyChain.createInstallIntent();
    installIntent.putExtra(KeyChain.EXTRA_PKCS12, keystore);
    startActivityForResult(installIntent, INSTALL_KEYSTORE_CODE);
    

    I also see people programmatically install only the certificate wrapped inside keystore:

    Intent intent = KeyChain.createInstallIntent();
    intent.putExtra(KeyChain.EXTRA_CERTIFICATE, cert);
    startActivity(intent);
    

    ...which leads --@Leem.fin question

    may find that the following link a better place to start:

    https://developer.android.com/studio/publish/app-signing.html#signing-manually

    0 讨论(0)
提交回复
热议问题