【问题标题】:Need to read certificate from smart card x509 oberthur c#需要从智能卡 x509 oberthur c# 读取证书
【发布时间】:2017-04-27 12:38:20
【问题描述】:

我在使用 BluDrive II 读卡器从新智能卡读取证书时遇到了一些问题。使用旧智能卡没有问题,但使用最新的智能卡在卡内没有发现证书。使用 bit4id 软件,我可以读取所有卡片(包含我需要的所有信息)。

            X509SecurityToken securityToken = null;
            var store = new X509Store();

            store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadOnly);



            try
            {
                Console.WriteLine("CERTIFICATI PRESENTI: {0}",store.Certificates.Count);
                X509Certificate2Collection certs = (X509Certificate2Collection)store.Certificates;

                if (certs.Count > 0)
                {
                    int i = 1;
                    foreach (var cert in certs)
                    {
                        securityToken = new X509SecurityToken(cert);
                        Console.WriteLine(".................................................................");
                        Console.WriteLine("CERTIFICATO {0}:\n\n {1}",i++, securityToken.Certificate);
                    }
                }
                else
                {
                    Console.WriteLine("NESSUN CERTIFICATO LETTO");
                    securityToken = null;
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                if (store != null)

                    store.Close();
            }

我是这个地方的新手,希望能得到您的帮助,非常感谢 :-) Ces@re

【问题讨论】:

  • 我不知道 c#,但我在您的代码中看不到用于访问卡的 PKCS11 库。您确定您的代码不是简单地读取与任何卡没有关系的空商店吗?

标签: c# smartcard x509 pkcs#11


【解决方案1】:

您不是直接从智能卡(通过 PKCS#11 库)读取证书,而是通过操作系统的证书存储(通过 X509Store 类)读取证书。因此,如果您的操作系统后端配置不正确,您将无法找到您的证书。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-01-28
    • 1970-01-01
    • 2012-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多