有没有办法使用X509Store的证书获取智能卡ATR

时间:2018-05-11 11:00:10

标签: c# .net x509certificate smartcard

我不确定如何通过X509Store

访问证书时获取智能卡ATR
var 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做些什么?

0 个答案:

没有答案