简体   繁体   English

X509Certificate IssuedTo / IssuedBy供用户从X509Store显示

[英]X509Certificate IssuedTo / IssuedBy for user display from X509Store

I need to show a user the list of Certificates from the X509Store and want to display the same information as per the MMC 'Certificate' snap in. Specifically looking to retrieve the "Issued To" and "Issued By" values. 我需要向用户显示X509Store的证书列表,并希望显示与MMC“证书”管理单元相同的信息。特别是要检索“颁发给”和“颁发者”值。

The 'Friendly name' is simple (string property of X509Certificate). “友好名称”很简单(X509Certificate的字符串属性)。

This is what I do to iterate a store and get the IssuedTo and IssuedBy values. 这就是我迭代存储并获取IssuedTo和IssuedBy值的方法。 You only need the middle bit, but this is a better working example snippet. 您只需要中间一点,但这是一个更好的示例示例。

// Iterate localmachine personal store

X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

store.Open(OpenFlags.ReadOnly);

foreach (var cert in store.Certificates)
{
    string s = String.Format("{0} ({1})", 
      cert.GetNameInfo(X509NameType.SimpleName, false), 
      cert.GetNameInfo(X509NameType.SimpleName, true)); 

    System.Console.WriteLine(s);
}

store.close();

Use the Issuer Property to get the Issuer and the Subject for Issued By. 使用Issuer属性获取颁发者和颁发者的Subject

Check MSDN . 检查MSDN

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM