1

I'm doing some smart card programming, and want to account for a situation where:

  1. The certificate from the card did not get imported into the local store (this is not a given, it's the source of the current problem)

  2. The name of the provider is not given

The second criteria means I can't rely on getting the certificate by creating an instance of an RSACryptoServiceProvider, like the following:

CspParameters cspParameters = new CspParameters(1, "provider name");
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cspParameters);

So, besides reading the names of all the providers from the registry from either HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider or HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\Cryptography\Defaults\Provider, and then creating an RSACryptoServiceProvider instance from each to see if the container identifies itself as a hardware device, it seems there'd be an easier way to access the certificates directly off the card reader.

I've looked at using P/Invoke and the APIs, but can't identify which API calls I can use for this either.

Random
  • 1,896
  • 3
  • 21
  • 33

0 Answers0