I have a Smart Card that I use to sign my documents. Now I am developing a c# application that can access the USB Reader with the card, retrieve the certificate and sign an XML. The ideal solution is to "copy" the certificate inside an X509Certificate2 object
.
I'm using this code right now:
List<X509Certificate2> certificates = new List<X509Certificate2>();
CspParameters cspParameters = new CspParameters(1, "Microsoft Base Smart Card Crypto Provider");
RSACryptoServiceProvider rsaProvider = new RSACryptoServiceProvider(cspParameters);
X509Store x509Store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
x509Store.Open(OpenFlags.ReadOnly);
foreach (X509Certificate2 cert in x509Store.Certificates)
{
certificates.Add(cert);
}
Inside the list I have some certificates, but not the one that is stored inside the Smart Card. Any suggestions?