保存在Android中保存签名的X509Certificate和PrivateKey



我想将x509certificate及其私钥保存到Android密钥店中,我想将X509Certificate(包含公共密钥)及其私有密钥"合并"。私钥用于创建CSR,然后服务器派对签署证书并返回应用程序,我可以将证书和私钥合并为一个独特的证书吗?另外,我正在使用Spongycastle(又名Bouncycastle的Android包装器)。

我对Android键盘不知道,但是也许您可以尝试以下操作:

PrivateKey privateKey = ...         //this is what you already have
X509Certificate certificate = ...   //this is what you already have
KeyStore keyStore = KeyStore.getInstance("AndroidKeyStore");
keyStore.load(null);
Certificate[] certChain = new Certificate[1];  
certChain[0] = certificate;  
char[] myKeyPassword = "myKeyPassword".toCharArray();
keyStore.setKeyEntry("mykeyalias", (Key)privateKey, myKeyPassword, certChain);  

请参阅https://docs.oracle.com/javase/9/docs/api/java/java/security/keystore.html#setkeyentry-java.lang.string-java.security.key-char-char:a-java。security.cert.certificate:A-有关keyStore.setKeyentry

的更多信息

相关内容

  • 没有找到相关文章

最新更新