简体   繁体   中英

smartcard and p12 file creation

I'm trying to create a p12 file (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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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