简体   繁体   中英

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.

The 'Friendly name' is simple (string property of X509Certificate).

This is what I do to iterate a store and get the IssuedTo and IssuedBy values. 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.

Check MSDN .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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