我不确定如何通过X509Store
访问证书时获取智能卡ATRvar store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
var sc = store.Certificates.OfType<X509Certificate2>().Where(x =>
x.HasPrivateKey &&
x.Extensions.OfType<X509KeyUsageExtension>()
.Any(y =>
y.KeyUsages.HasFlag(X509KeyUsageFlags.DigitalSignature) &&
y.KeyUsages.HasFlag(X509KeyUsageFlags.NonRepudiation))
).ToList();
store.Close();
foreach (var x509Certificate2 in sc)
{
var csp = (RSACryptoServiceProvider)x509Certificate2.PrivateKey;
if (csp.CspKeyContainerInfo.HardwareDevice)
{
Console.WriteLine("ATR: ???");
}
}
也许我可以用csp.CspKeyContainerInfo.UniqueKeyContainerName
做些什么?