:-(
I am trying to use an ACOS5 smart card from Advanced Card Systems (ACS)
using several different readers in conjunction with the
RSACryptoServiceProvider and I have hit a wall. I can successfully access
the smart card using IE (got a personal cert from Comodo) and via ACS's
Smart Card Cert Manager, but when I attempt to access the card via code
(C#), I get an exception: "The handle is invalid", regardless of what I do.
I have tried both the "Microsoft Base Smart Card Crypto Provider" and the
"Advanced Card Systems CSP v1.5" providers. Here is the code...
CspParameters cspParams = new CspParameters();
cspParams.ProviderName = "Advanced Card Systems CSP v1.5";
cspParams.Flags = CspProviderFlags.UseDefaultKeyContainer;
cspParams.ProviderType = 1;
cspParams.KeyNumber = 2;
m_RSAalg = new RSACryptoServiceProvider(cspParams);
Here is the relevant part of the stack trace:
at System.Security.Cryptography.Utils.GetKeyPairHelpe r(CspAlgorithmType
keyType, CspParameters parameters, Boolean randomKeyContainer, Int32
dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvi der.GetKeyPair()
at System.Security.Cryptography.RSACryptoServiceProvi der..ctor(Int32
dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
at
System.Security.Cryptography.RSACryptoServiceProvi der..ctor(CspParameters
parameters)
Help...
:-(
--
Peter DeBetta, MVP - SQL Server
http://sqlblog.com
--