【问题标题】:What should be SetCertificate() arguments for this certificate?该证书的 SetCertificate() 参数应该是什么?
【发布时间】:2017-05-25 16:06:49
【问题描述】:

对于此证书,以下调用的参数应该是什么?我尝试了以下方法,但没有成功。

X509CertificateInitiatorClientCredential.ClientCertificate.SetCertificate(
     StoreLocation.LocalMachine
    ,StoreName.CertificateAuthority
    ,X509FindType.FindBySubjectName
    ,"CN=MPCA" // also tried without CN=
);

【问题讨论】:

  • 您是否收到任何类型的错误?
  • 另外,您可能想要修改您的代码并测试证书是否在您期望的位置并且可以访问。这:stackoverflow.com/questions/4729302/… 显示如何从存储中检索所有证书。
  • 错误很明显:找不到证书。

标签: c# x509certificate


【解决方案1】:

证书工具的 TrustedRootCertificateAuthorities 存储名称映射到 .NET X509 API 中的 StoreName.Root

X509CertificateInitiatorClientCredential.ClientCertificate.SetCertificate(
     StoreLocation.LocalMachine
    ,StoreName.Root
    ,X509FindType.FindBySerialNumber
    ,"FA###########434" // serial found by enumerating all certs
);

或者:

X509CertificateInitiatorClientCredential.ClientCertificate.SetCertificate(
     StoreLocation.LocalMachine
    ,StoreName.Root
    ,X509FindType.FindBySubjectName
    ,"MPCA" // Without CN=
);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-09-18
    • 2018-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多