I'm trying to develop a simple C# signature API to be used by a web intranet procedure. This signature API must allow a subject connected to the web application to use his certificate (on a smart card or on a USB stick) to sign a document (a PDF file).
When I try to initialize an RSACryptoServiceProvider as suggested here: http://msdn.microsoft.com/en-us/library/ms229931.aspx:
// Create a new CspParameters object that identifies a
// Smart Card CryptoGraphic Provider.
// The 1st parameter comes from
// HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider Types.
// The 2nd parameter comes from
// HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider.
CspParameters csp = new CspParameters(1, "Schlumberger Cryptographic Service Provider");
csp.Flags = CspProviderFlags.UseDefaultKeyContainer;
// Initialize an RSACryptoServiceProvider object using
// the CspParameters object.
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(csp);
I get a CryptographicException:
keyset does not exist
I looked at the windows registry under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\Defaults\Provider
and did not find any smart card provider.
I'm using a Dell Latitude with a card reader and installed all the drivers (I think so...).
So my questions are:
- The provider specified in the parameters is for using the reader or for reading the card, or both?
- Is there a generic smart card CSP publicly available or should it be tipically delivered with the smart card?
- May I use other types certificates (e.g. a CA signed or self signed certificate stored on disk or USB stick)? How?