简体   繁体   English

智能卡和p12文件创建

[英]smartcard and p12 file creation

I'm trying to create a p12 file (pkcs12). 我正在尝试创建一个p12文件(pkcs12)。 I know that i need a certificate and a private key to create it. 我知道我需要创建证书和私钥。 I read the certificate from smart card, but i have problems with private key. 我从智能卡读取了证书,但是私钥有问题。 I know that in smart card there is a private key, but i cannot extract it...is it true? 我知道智能卡中有一个私钥,但是我无法提取它……是真的吗? There is another way to use the private key stored in smart card and use it to create the p12 file? 还有另一种方法来使用存储在智能卡中的私钥并使用它来创建p12文件吗?

I want to use this code: 我想使用以下代码:

 KeyStore store = KeyStore.getInstance("PKCS12");  
 store.load(null, null);


 store.setKeyEntry("Eric's Key", privKey, null, certificate);

 FileOutputStream fOut = new FileOutputStream("id.p12");

 store.store(fOut, passwd);

Any suggestion please? 有什么建议吗? Thanks 谢谢

No, you generally cannot extract the private key from a Smart Card. 不,您通常无法从智能卡中提取私钥。 Sometimes there are backup or key wrapping functions available, but you would require special access for that. 有时有备份或密钥包装功能可用,但是您需要特殊的访问权限。 PKCS#12 is a binary format for storing keys and certificate, so you do require access to the private key to create one. PKCS#12是用于存储密钥和证书的二进制格式,因此您确实需要访问私钥才能创建密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM