Use the AsnEncodedDataCollection class. : AsnEncodedDataCollection « Security « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Security » AsnEncodedDataCollectionScreenshots 
Use the AsnEncodedDataCollection class.
  

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()
      Dim As Integer
      For i = To scollection.Count - 1
          Console.WriteLine(scollection(i).GetName())
          Dim extension As X509Extension
          For Each extension In  scollection(i).Extensions
              Dim asndata As New AsnEncodedData(extension.Oid, extension.RawData)
              Console.WriteLine("Extension type: " & extension.Oid.FriendlyName)
              Console.WriteLine("Oid value: " & asndata.Oid.Value )
              Console.WriteLine("Raw data length: " & asndata.RawData.Length)
              Console.WriteLine(asndata.Format(True))
               asncoll.Add(asndata)
          Next extension
      Next i
      Console.WriteLine("Number of AsnEncodedData items in the collection: " & asncoll.Count)
      store.Close()

   End Sub
End Class

   
    
  
Related examples in the same category
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.