Move through X509Certificate2Collection
Imports System
Imports System.Security.Cryptography
Imports System.Security.Cryptography.X509Certificates
Class MainClass
Shared Sub Main()
Dim store As New X509Store("MY", StoreLocation.CurrentUser)
store.Open((OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly))
Dim collection As X509Certificate2Collection = CType(store.Certificates, X509Certificate2Collection)
Dim fcollection As X509Certificate2Collection = CType(collection.Find(X509FindType.FindByTimeValid, DateTime.Now, False), X509Certificate2Collection)
Dim scollection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(fcollection, "Certificate Select", "Select certificates from the following list to get extension information on that certificate", X509SelectionFlag.MultiSelection)
Dim asncoll As New AsnEncodedDataCollection()
'Create an enumerator for moving through the collection.
Dim asne As AsnEncodedDataEnumerator = asncoll.GetEnumerator()
'You must execute a MoveNext() to get to the first item in the collection.
asne.MoveNext()
' Write out AsnEncodedData in the collection.
Console.WriteLine("First AsnEncodedData in the collection: " & asne.Current.Format(True))
asne.MoveNext()
Console.WriteLine("Second AsnEncodedData in the collection: " & asne.Current.Format(True))
'Return index in the collection to the beginning.
asne.Reset()
End Sub
End Class
Related examples in the same category