using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
class MainClass
{
static void Main()
{
X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates;
X509Certificate2Collection fcollection = (X509Certificate2Collection)collection.Find(X509FindType.FindByTimeValid, DateTime.Now, false);
X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection, "Certificate Select", "Select certificates from the following list to get extension information on that certificate", X509SelectionFlag.MultiSelection);
AsnEncodedDataCollection asncoll = new AsnEncodedDataCollection();
for (int i = 0; i < scollection.Count; i++)
{
Console.WriteLine( scollection[i].GetName());
foreach (X509Extension extension in scollection[i].Extensions)
{
AsnEncodedData asndata = new AsnEncodedData(extension.Oid, extension.RawData);
Console.WriteLine(extension.Oid.FriendlyName);
Console.WriteLine(asndata.Oid.Value);
Console.WriteLine(asndata.RawData.Length);
Console.WriteLine(asndata.Format(true));
asncoll.Add(asndata);
}
}
Console.WriteLine(asncoll.Count);
store.Close();
AsnEncodedDataEnumerator asne = asncoll.GetEnumerator();
asne.MoveNext();
Console.WriteLine(asne.Current.Format(true));
asne.MoveNext();
Console.WriteLine(asne.Current.Format(true));
asne.Reset();
}
}
35.19.AsnEncodedDataCollection |
| 35.19.1. | Use the AsnEncodedDataCollection class. |