gpt4 book ai didi

android - 如何将 .p12 证书添加到 Android 设备?

转载 作者:行者123 更新时间:2023-11-29 01:44:10 47 4
gpt4 key购买 nike

我在将 .p12 证书加载到我的 Android 项目时遇到问题。这是一段源代码:

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

第 2 行打开证书文件时出错。

如何将证书文件正确添加到我的 Android 程序中?

最佳答案

...

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

可能会发现以下链接是更好的起点:

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

关于android - 如何将 .p12 证书添加到 Android 设备?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22506040/

47 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com