Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access certificate and private key from pkcs#11 token or smart-card

I am making an application, in C#4, that has to sign a XML file. I'd no great problems, until I bumped into this: accessing a smart-card/token to get its certificates and private keys.
Nothing really out of the box, just get the certificate and key, based in a password.

Does anyone know how to do it without any paid framework?

like image 543
marcelo-ferraz Avatar asked Dec 07 '11 21:12

marcelo-ferraz


1 Answers

The Microsoft Crypto API's support the ability to interact with hardware devices out of the box. This will require that your card have a driver provided by the manufacture though. Depending on the card and OS the driver may have already downloaded for you. The following .NET article should help you at least get started and see if you can use some of the MSoft API's out of the box. http://msdn.microsoft.com/en-us/library/ms229931.aspx.

If you have additional information about the type of card you are utilizing you may be able to use PC/SC and specific APDU commands to ask the card to sign or encrypt information for you. It is common for card applets to not permit retrieval of a certificates private key for security reasons.

Good Luck. Add a comment if you have some more questions about this.

like image 128
Chris Evans Avatar answered Sep 24 '22 00:09

Chris Evans