AsnEncodedDataとは? わかりやすく解説

AsnEncodedData クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

ASN.1 (Abstract Syntax Notation One) でエンコードされたデータ表します

名前空間: System.Security.Cryptography
アセンブリ: System (system.dll 内)
構文構文

Public Class AsnEncodedData
Dim instance As AsnEncodedData
public class AsnEncodedData
public ref class AsnEncodedData
public class AsnEncodedData
public class AsnEncodedData
解説解説
使用例使用例

AsnEncodedData クラス使用するコード例次に示します

Imports System
Imports System.Security.Cryptography
Imports System.Security.Cryptography.X509Certificates



Class AsnEncodedDataSample
   Shared msg As String
   Shared Sub Main()
      'The following example demonstrates the usage the AsnEncodedData
 classes.
      ' Asn encoded data is read from the extensions of an X509 certificate.
      Try
         ' Open the certificate store.
         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)
         ' Select one or more certificates to display extensions information.
         Dim scollection As X509Certificate2Collection
 = X509Certificate2UI.SelectFromCollection(fcollection, "Certificate
 Select", "Select certificates from the following list to get extension information on that certificate", X509SelectionFlag.MultiSelection)
         
         ' Create a new AsnEncodedDataCollection object.
         Dim asncoll As New
 AsnEncodedDataCollection()
         Dim i As Integer
         For i = 0 To scollection.Count - 1
            ' Display certificate information.
        msg = "Certificate name: "& scollection(i).GetName()
            MsgBox(msg)

            ' Display extensions information.
            Dim extension As X509Extension
            For Each extension In
  scollection(i).Extensions
               ' Create an AsnEncodedData object using the extensions
 information.
               Dim asndata As New
 AsnEncodedData(extension.Oid, extension.RawData)
           msg = "Extension type: " & extension.Oid.FriendlyName
 & Environment.NewLine & "Oid value: " &
 asndata.Oid.Value _
        & Environment.NewLine & "Raw data length: "
 & asndata.RawData.Length & Environment.NewLine _
        & asndata.Format(True) & Environment.NewLine
               MsgBox(msg)
        
               ' Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
               asncoll.Add(asndata)
            Next extension
         Next i
     msg = "Number of AsnEncodedData items in the collection:
 " & asncoll.Count
         MsgBox(msg)         
         store.Close()

         '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.
     msg = "First AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
    
         
         asne.MoveNext()
     msg = "Second AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
        
         'Return index in the collection to the beginning.
         asne.Reset()
      Catch 
         MsgBox("Information could not be written out for this
 certificate.")
      End Try
   End Sub 'Main
End Class 'AsnEncodedDataSample
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

class AsnEncodedDataSample
{
    static void Main()
    {        
        //The following example demonstrates the usage the AsnEncodedData
 classes.
        // Asn encoded data is read from the extensions of an X509 certificate.
        try
        {
            // Open the certificate store.
            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);
            // Select one or more certificates to display extensions
 information.
            X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection,
 "Certificate Select", "Select certificates from the following list
 to get extension information on that certificate", X509SelectionFlag.MultiSelection);

            // Create a new AsnEncodedDataCollection object.
            AsnEncodedDataCollection asncoll = new AsnEncodedDataCollection();
            for (int i = 0; i < scollection.Count;
 i++)
            {
                // Display certificate information.
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Certificate name: {0}", scollection[i].GetName());
                Console.ResetColor();
                // Display extensions information.
                foreach (X509Extension extension in
 scollection[i].Extensions)
                {
                    // Create an AsnEncodedData object using the extensions
 information.
                    AsnEncodedData asndata = new AsnEncodedData(extension.Oid,
 extension.RawData);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Extension type: {0}", extension.Oid.FriendlyName);
                    Console.WriteLine("Oid value: {0}",asndata.Oid.Value);
                    Console.WriteLine("Raw data length: {0} {1}", asndata.RawData.Length,
 Environment.NewLine);
                    Console.ResetColor();
                    Console.WriteLine(asndata.Format(true));
                    Console.WriteLine(Environment.NewLine);
                    // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
                    asncoll.Add(asndata);
                }
                Console.WriteLine(Environment.NewLine);
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll.Count, Environment.NewLine);
            Console.ResetColor();

            store.Close();
            //Create an enumerator for moving through the collection.
            AsnEncodedDataEnumerator asne = 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.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("First AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();

            asne.MoveNext();
            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("Second AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();
            //Return index in the collection to the beginning.
            asne.Reset();
        }
        catch (CryptographicException)
        {
            Console.WriteLine("Information could not be written out for
 this certificate.");
        }
    }
}
#using <System.dll>
#using <System.Security.dll>

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Security::Cryptography::X509Certificates;

int main()
{
   
   //The following example demonstrates the usage of the AsnEncodedData
 classes.
   // Asn encoded data is read from the extensions of an X509 certificate.
   try
   {
      
      // Open the certificate store.
      X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser
 );
      store->Open( static_cast<OpenFlags>(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly)
 );
      X509Certificate2Collection^ collection = dynamic_cast<X509Certificate2Collection^>(store->Certificates);
      X509Certificate2Collection^ fcollection = dynamic_cast<X509Certificate2Collection^>(collection->Find(
 X509FindType::FindByTimeValid, DateTime::Now, false ));
      
      // Select one or more certificates to display extensions information.
      X509Certificate2Collection^ scollection = X509Certificate2UI::SelectFromCollection(fcollection,
 L"Certificate Select",L"Select certificates from the following list
 to get extension information on that certificate",X509SelectionFlag::MultiSelection);
      
      // Create a new AsnEncodedDataCollection object.
      AsnEncodedDataCollection^ asncoll = gcnew AsnEncodedDataCollection;
      for ( int i = 0; i < scollection->Count;
 i++ )
      {
         
         // Display certificate information.
         Console::ForegroundColor = ConsoleColor::Red;
         Console::WriteLine( L"Certificate name: {0}", scollection[i]->GetName()
 );
         Console::ResetColor();
         
         // Display extensions information.
         System::Collections::IEnumerator^ myEnum = scollection[i]->Extensions->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            X509Extension^ extension = safe_cast<X509Extension ^>(myEnum->Current);
            
            // Create an AsnEncodedData object using the extensions
 information.
            AsnEncodedData^ asndata = gcnew AsnEncodedData( extension->Oid,extension->RawData
 );
            Console::ForegroundColor = ConsoleColor::Green;
            Console::WriteLine( L"Extension type: {0}", extension->Oid->FriendlyName
 );
            Console::WriteLine( L"Oid value: {0}", asndata->Oid->Value
 );
            Console::WriteLine( L"Raw data length: {0} {1}", asndata->RawData->Length,
 Environment::NewLine );
            Console::ResetColor();
            Console::WriteLine( asndata->Format(true) );
            Console::WriteLine( Environment::NewLine );
            
            // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
            asncoll->Add( asndata );
         }

         Console::WriteLine( Environment::NewLine );

      }
      Console::ForegroundColor = ConsoleColor::Red;
      Console::WriteLine( L"Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll->Count, Environment::NewLine );
      Console::ResetColor();
      store->Close();
      
      //Create an enumerator for moving through the collection.
      AsnEncodedDataEnumerator^ asne = 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::ForegroundColor = ConsoleColor::Blue;
      Console::WriteLine( L"First AsnEncodedData in the collection:
 {0}", asne->Current->Format(true) );
      Console::ResetColor();
      asne->MoveNext();
      Console::ForegroundColor = ConsoleColor::DarkBlue;
      Console::WriteLine( L"Second AsnEncodedData in the
 collection: {0}", asne->Current->Format(true) );
      Console::ResetColor();
      
      //Return index in the collection to the beginning.
      asne->Reset();
   }
   catch ( CryptographicException^ ) 
   {
      Console::WriteLine( L"Information could not be written out for
 this certificate." );
   }

   return 1;
}
継承階層継承階層
System.Object
  System.Security.Cryptography.AsnEncodedData
     System.Security.Cryptography.Pkcs.Pkcs9AttributeObject
     System.Security.Cryptography.X509Certificates.X500DistinguishedName
     System.Security.Cryptography.X509Certificates.X509Extension
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AsnEncodedData メンバ
System.Security.Cryptography 名前空間

AsnEncodedData コンストラクタ ()

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

AsnEncodedData クラス新しインスタンス初期化します。

名前空間: System.Security.Cryptography
アセンブリ: System (system.dll 内)
構文構文

Dim instance As New AsnEncodedData
protected AsnEncodedData ()
protected:
AsnEncodedData ()
protected AsnEncodedData ()
protected function AsnEncodedData ()
使用例使用例

AsnEncodedData クラス使用するコード例次に示します

Imports System
Imports System.Security.Cryptography
Imports System.Security.Cryptography.X509Certificates



Class AsnEncodedDataSample
   Shared msg As String
   Shared Sub Main()
      'The following example demonstrates the usage the AsnEncodedData
 classes.
      ' Asn encoded data is read from the extensions of an X509 certificate.
      Try
         ' Open the certificate store.
         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)
         ' Select one or more certificates to display extensions information.
         Dim scollection As X509Certificate2Collection
 = X509Certificate2UI.SelectFromCollection(fcollection, "Certificate
 Select", "Select certificates from the following list to get extension information on that certificate", X509SelectionFlag.MultiSelection)
         
         ' Create a new AsnEncodedDataCollection object.
         Dim asncoll As New
 AsnEncodedDataCollection()
         Dim i As Integer
         For i = 0 To scollection.Count - 1
            ' Display certificate information.
        msg = "Certificate name: "& scollection(i).GetName()
            MsgBox(msg)

            ' Display extensions information.
            Dim extension As X509Extension
            For Each extension In
  scollection(i).Extensions
               ' Create an AsnEncodedData object using the extensions
 information.
               Dim asndata As New
 AsnEncodedData(extension.Oid, extension.RawData)
           msg = "Extension type: " & extension.Oid.FriendlyName
 & Environment.NewLine & "Oid value: " &
 asndata.Oid.Value _
        & Environment.NewLine & "Raw data length: "
 & asndata.RawData.Length & Environment.NewLine _
        & asndata.Format(True) & Environment.NewLine
               MsgBox(msg)
        
               ' Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
               asncoll.Add(asndata)
            Next extension
         Next i
     msg = "Number of AsnEncodedData items in the collection:
 " & asncoll.Count
         MsgBox(msg)         
         store.Close()

         '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.
     msg = "First AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
    
         
         asne.MoveNext()
     msg = "Second AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
        
         'Return index in the collection to the beginning.
         asne.Reset()
      Catch 
         MsgBox("Information could not be written out for this
 certificate.")
      End Try
   End Sub 'Main
End Class 'AsnEncodedDataSample
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

class AsnEncodedDataSample
{
    static void Main()
    {        
        //The following example demonstrates the usage the AsnEncodedData
 classes.
        // Asn encoded data is read from the extensions of an X509 certificate.
        try
        {
            // Open the certificate store.
            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);
            // Select one or more certificates to display extensions
 information.
            X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection,
 "Certificate Select", "Select certificates from the following list
 to get extension information on that certificate", X509SelectionFlag.MultiSelection);

            // Create a new AsnEncodedDataCollection object.
            AsnEncodedDataCollection asncoll = new AsnEncodedDataCollection();
            for (int i = 0; i < scollection.Count;
 i++)
            {
                // Display certificate information.
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Certificate name: {0}", scollection[i].GetName());
                Console.ResetColor();
                // Display extensions information.
                foreach (X509Extension extension in
 scollection[i].Extensions)
                {
                    // Create an AsnEncodedData object using the extensions
 information.
                    AsnEncodedData asndata = new AsnEncodedData(extension.Oid,
 extension.RawData);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Extension type: {0}", extension.Oid.FriendlyName);
                    Console.WriteLine("Oid value: {0}",asndata.Oid.Value);
                    Console.WriteLine("Raw data length: {0} {1}", asndata.RawData.Length,
 Environment.NewLine);
                    Console.ResetColor();
                    Console.WriteLine(asndata.Format(true));
                    Console.WriteLine(Environment.NewLine);
                    // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
                    asncoll.Add(asndata);
                }
                Console.WriteLine(Environment.NewLine);
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll.Count, Environment.NewLine);
            Console.ResetColor();

            store.Close();
            //Create an enumerator for moving through the collection.
            AsnEncodedDataEnumerator asne = 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.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("First AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();

            asne.MoveNext();
            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("Second AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();
            //Return index in the collection to the beginning.
            asne.Reset();
        }
        catch (CryptographicException)
        {
            Console.WriteLine("Information could not be written out for
 this certificate.");
        }
    }
}
#using <System.dll>
#using <System.Security.dll>

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Security::Cryptography::X509Certificates;

int main()
{
   
   //The following example demonstrates the usage of the AsnEncodedData
 classes.
   // Asn encoded data is read from the extensions of an X509 certificate.
   try
   {
      
      // Open the certificate store.
      X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser
 );
      store->Open( static_cast<OpenFlags>(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly)
 );
      X509Certificate2Collection^ collection = dynamic_cast<X509Certificate2Collection^>(store->Certificates);
      X509Certificate2Collection^ fcollection = dynamic_cast<X509Certificate2Collection^>(collection->Find(
 X509FindType::FindByTimeValid, DateTime::Now, false ));
      
      // Select one or more certificates to display extensions information.
      X509Certificate2Collection^ scollection = X509Certificate2UI::SelectFromCollection(fcollection,
 L"Certificate Select",L"Select certificates from the following list
 to get extension information on that certificate",X509SelectionFlag::MultiSelection);
      
      // Create a new AsnEncodedDataCollection object.
      AsnEncodedDataCollection^ asncoll = gcnew AsnEncodedDataCollection;
      for ( int i = 0; i < scollection->Count;
 i++ )
      {
         
         // Display certificate information.
         Console::ForegroundColor = ConsoleColor::Red;
         Console::WriteLine( L"Certificate name: {0}", scollection[i]->GetName()
 );
         Console::ResetColor();
         
         // Display extensions information.
         System::Collections::IEnumerator^ myEnum = scollection[i]->Extensions->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            X509Extension^ extension = safe_cast<X509Extension ^>(myEnum->Current);
            
            // Create an AsnEncodedData object using the extensions
 information.
            AsnEncodedData^ asndata = gcnew AsnEncodedData( extension->Oid,extension->RawData
 );
            Console::ForegroundColor = ConsoleColor::Green;
            Console::WriteLine( L"Extension type: {0}", extension->Oid->FriendlyName
 );
            Console::WriteLine( L"Oid value: {0}", asndata->Oid->Value
 );
            Console::WriteLine( L"Raw data length: {0} {1}", asndata->RawData->Length,
 Environment::NewLine );
            Console::ResetColor();
            Console::WriteLine( asndata->Format(true) );
            Console::WriteLine( Environment::NewLine );
            
            // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
            asncoll->Add( asndata );
         }

         Console::WriteLine( Environment::NewLine );

      }
      Console::ForegroundColor = ConsoleColor::Red;
      Console::WriteLine( L"Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll->Count, Environment::NewLine );
      Console::ResetColor();
      store->Close();
      
      //Create an enumerator for moving through the collection.
      AsnEncodedDataEnumerator^ asne = 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::ForegroundColor = ConsoleColor::Blue;
      Console::WriteLine( L"First AsnEncodedData in the collection:
 {0}", asne->Current->Format(true) );
      Console::ResetColor();
      asne->MoveNext();
      Console::ForegroundColor = ConsoleColor::DarkBlue;
      Console::WriteLine( L"Second AsnEncodedData in the
 collection: {0}", asne->Current->Format(true) );
      Console::ResetColor();
      
      //Return index in the collection to the beginning.
      asne->Reset();
   }
   catch ( CryptographicException^ ) 
   {
      Console::WriteLine( L"Information could not be written out for
 this certificate." );
   }

   return 1;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AsnEncodedData クラス
AsnEncodedData メンバ
System.Security.Cryptography 名前空間

AsnEncodedData コンストラクタ (AsnEncodedData)

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

AsnEncodedData クラス新しインスタンスを、AsnEncodedData クラスインスタンス使用して初期化します。

名前空間: System.Security.Cryptography
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    asnEncodedData As AsnEncodedData _
)
Dim asnEncodedData As AsnEncodedData

Dim instance As New AsnEncodedData(asnEncodedData)
public AsnEncodedData (
    AsnEncodedData asnEncodedData
)
public:
AsnEncodedData (
    AsnEncodedData^ asnEncodedData
)
public AsnEncodedData (
    AsnEncodedData asnEncodedData
)
public function AsnEncodedData (
    asnEncodedData : AsnEncodedData
)

パラメータ

asnEncodedData

AsnEncodedData クラスインスタンス

解説解説
使用例使用例

AsnEncodedData クラス使用するコード例次に示します

Imports System
Imports System.Security.Cryptography
Imports System.Security.Cryptography.X509Certificates



Class AsnEncodedDataSample
   Shared msg As String
   Shared Sub Main()
      'The following example demonstrates the usage the AsnEncodedData
 classes.
      ' Asn encoded data is read from the extensions of an X509 certificate.
      Try
         ' Open the certificate store.
         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)
         ' Select one or more certificates to display extensions information.
         Dim scollection As X509Certificate2Collection
 = X509Certificate2UI.SelectFromCollection(fcollection, "Certificate
 Select", "Select certificates from the following list to get extension information on that certificate", X509SelectionFlag.MultiSelection)
         
         ' Create a new AsnEncodedDataCollection object.
         Dim asncoll As New
 AsnEncodedDataCollection()
         Dim i As Integer
         For i = 0 To scollection.Count - 1
            ' Display certificate information.
        msg = "Certificate name: "& scollection(i).GetName()
            MsgBox(msg)

            ' Display extensions information.
            Dim extension As X509Extension
            For Each extension In
  scollection(i).Extensions
               ' Create an AsnEncodedData object using the extensions
 information.
               Dim asndata As New
 AsnEncodedData(extension.Oid, extension.RawData)
           msg = "Extension type: " & extension.Oid.FriendlyName
 & Environment.NewLine & "Oid value: " &
 asndata.Oid.Value _
        & Environment.NewLine & "Raw data length: "
 & asndata.RawData.Length & Environment.NewLine _
        & asndata.Format(True) & Environment.NewLine
               MsgBox(msg)
        
               ' Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
               asncoll.Add(asndata)
            Next extension
         Next i
     msg = "Number of AsnEncodedData items in the collection:
 " & asncoll.Count
         MsgBox(msg)         
         store.Close()

         '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.
     msg = "First AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
    
         
         asne.MoveNext()
     msg = "Second AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
        
         'Return index in the collection to the beginning.
         asne.Reset()
      Catch 
         MsgBox("Information could not be written out for this
 certificate.")
      End Try
   End Sub 'Main
End Class 'AsnEncodedDataSample
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

class AsnEncodedDataSample
{
    static void Main()
    {        
        //The following example demonstrates the usage the AsnEncodedData
 classes.
        // Asn encoded data is read from the extensions of an X509 certificate.
        try
        {
            // Open the certificate store.
            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);
            // Select one or more certificates to display extensions
 information.
            X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection,
 "Certificate Select", "Select certificates from the following list
 to get extension information on that certificate", X509SelectionFlag.MultiSelection);

            // Create a new AsnEncodedDataCollection object.
            AsnEncodedDataCollection asncoll = new AsnEncodedDataCollection();
            for (int i = 0; i < scollection.Count;
 i++)
            {
                // Display certificate information.
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Certificate name: {0}", scollection[i].GetName());
                Console.ResetColor();
                // Display extensions information.
                foreach (X509Extension extension in
 scollection[i].Extensions)
                {
                    // Create an AsnEncodedData object using the extensions
 information.
                    AsnEncodedData asndata = new AsnEncodedData(extension.Oid,
 extension.RawData);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Extension type: {0}", extension.Oid.FriendlyName);
                    Console.WriteLine("Oid value: {0}",asndata.Oid.Value);
                    Console.WriteLine("Raw data length: {0} {1}", asndata.RawData.Length,
 Environment.NewLine);
                    Console.ResetColor();
                    Console.WriteLine(asndata.Format(true));
                    Console.WriteLine(Environment.NewLine);
                    // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
                    asncoll.Add(asndata);
                }
                Console.WriteLine(Environment.NewLine);
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll.Count, Environment.NewLine);
            Console.ResetColor();

            store.Close();
            //Create an enumerator for moving through the collection.
            AsnEncodedDataEnumerator asne = 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.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("First AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();

            asne.MoveNext();
            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("Second AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();
            //Return index in the collection to the beginning.
            asne.Reset();
        }
        catch (CryptographicException)
        {
            Console.WriteLine("Information could not be written out for
 this certificate.");
        }
    }
}
#using <System.dll>
#using <System.Security.dll>

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Security::Cryptography::X509Certificates;

int main()
{
   
   //The following example demonstrates the usage of the AsnEncodedData
 classes.
   // Asn encoded data is read from the extensions of an X509 certificate.
   try
   {
      
      // Open the certificate store.
      X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser
 );
      store->Open( static_cast<OpenFlags>(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly)
 );
      X509Certificate2Collection^ collection = dynamic_cast<X509Certificate2Collection^>(store->Certificates);
      X509Certificate2Collection^ fcollection = dynamic_cast<X509Certificate2Collection^>(collection->Find(
 X509FindType::FindByTimeValid, DateTime::Now, false ));
      
      // Select one or more certificates to display extensions information.
      X509Certificate2Collection^ scollection = X509Certificate2UI::SelectFromCollection(fcollection,
 L"Certificate Select",L"Select certificates from the following list
 to get extension information on that certificate",X509SelectionFlag::MultiSelection);
      
      // Create a new AsnEncodedDataCollection object.
      AsnEncodedDataCollection^ asncoll = gcnew AsnEncodedDataCollection;
      for ( int i = 0; i < scollection->Count;
 i++ )
      {
         
         // Display certificate information.
         Console::ForegroundColor = ConsoleColor::Red;
         Console::WriteLine( L"Certificate name: {0}", scollection[i]->GetName()
 );
         Console::ResetColor();
         
         // Display extensions information.
         System::Collections::IEnumerator^ myEnum = scollection[i]->Extensions->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            X509Extension^ extension = safe_cast<X509Extension ^>(myEnum->Current);
            
            // Create an AsnEncodedData object using the extensions
 information.
            AsnEncodedData^ asndata = gcnew AsnEncodedData( extension->Oid,extension->RawData
 );
            Console::ForegroundColor = ConsoleColor::Green;
            Console::WriteLine( L"Extension type: {0}", extension->Oid->FriendlyName
 );
            Console::WriteLine( L"Oid value: {0}", asndata->Oid->Value
 );
            Console::WriteLine( L"Raw data length: {0} {1}", asndata->RawData->Length,
 Environment::NewLine );
            Console::ResetColor();
            Console::WriteLine( asndata->Format(true) );
            Console::WriteLine( Environment::NewLine );
            
            // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
            asncoll->Add( asndata );
         }

         Console::WriteLine( Environment::NewLine );

      }
      Console::ForegroundColor = ConsoleColor::Red;
      Console::WriteLine( L"Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll->Count, Environment::NewLine );
      Console::ResetColor();
      store->Close();
      
      //Create an enumerator for moving through the collection.
      AsnEncodedDataEnumerator^ asne = 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::ForegroundColor = ConsoleColor::Blue;
      Console::WriteLine( L"First AsnEncodedData in the collection:
 {0}", asne->Current->Format(true) );
      Console::ResetColor();
      asne->MoveNext();
      Console::ForegroundColor = ConsoleColor::DarkBlue;
      Console::WriteLine( L"Second AsnEncodedData in the
 collection: {0}", asne->Current->Format(true) );
      Console::ResetColor();
      
      //Return index in the collection to the beginning.
      asne->Reset();
   }
   catch ( CryptographicException^ ) 
   {
      Console::WriteLine( L"Information could not be written out for
 this certificate." );
   }

   return 1;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AsnEncodedData クラス
AsnEncodedData メンバ
System.Security.Cryptography 名前空間

AsnEncodedData コンストラクタ (Oid, Byte[])

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

Oid オブジェクトバイト配列使用して、AsnEncodedData クラス新しインスタンス初期化します。

名前空間: System.Security.Cryptography
アセンブリ: System (system.dll 内)
構文構文

使用例使用例

AsnEncodedData クラス使用するコード例次に示します

Imports System
Imports System.Security.Cryptography
Imports System.Security.Cryptography.X509Certificates



Class AsnEncodedDataSample
   Shared msg As String
   Shared Sub Main()
      'The following example demonstrates the usage the AsnEncodedData
 classes.
      ' Asn encoded data is read from the extensions of an X509 certificate.
      Try
         ' Open the certificate store.
         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)
         ' Select one or more certificates to display extensions information.
         Dim scollection As X509Certificate2Collection
 = X509Certificate2UI.SelectFromCollection(fcollection, "Certificate
 Select", "Select certificates from the following list to get extension information on that certificate", X509SelectionFlag.MultiSelection)
         
         ' Create a new AsnEncodedDataCollection object.
         Dim asncoll As New
 AsnEncodedDataCollection()
         Dim i As Integer
         For i = 0 To scollection.Count - 1
            ' Display certificate information.
        msg = "Certificate name: "& scollection(i).GetName()
            MsgBox(msg)

            ' Display extensions information.
            Dim extension As X509Extension
            For Each extension In
  scollection(i).Extensions
               ' Create an AsnEncodedData object using the extensions
 information.
               Dim asndata As New
 AsnEncodedData(extension.Oid, extension.RawData)
           msg = "Extension type: " & extension.Oid.FriendlyName
 & Environment.NewLine & "Oid value: " &
 asndata.Oid.Value _
        & Environment.NewLine & "Raw data length: "
 & asndata.RawData.Length & Environment.NewLine _
        & asndata.Format(True) & Environment.NewLine
               MsgBox(msg)
        
               ' Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
               asncoll.Add(asndata)
            Next extension
         Next i
     msg = "Number of AsnEncodedData items in the collection:
 " & asncoll.Count
         MsgBox(msg)         
         store.Close()

         '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.
     msg = "First AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
    
         
         asne.MoveNext()
     msg = "Second AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
        
         'Return index in the collection to the beginning.
         asne.Reset()
      Catch 
         MsgBox("Information could not be written out for this
 certificate.")
      End Try
   End Sub 'Main
End Class 'AsnEncodedDataSample
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

class AsnEncodedDataSample
{
    static void Main()
    {        
        //The following example demonstrates the usage the AsnEncodedData
 classes.
        // Asn encoded data is read from the extensions of an X509 certificate.
        try
        {
            // Open the certificate store.
            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);
            // Select one or more certificates to display extensions
 information.
            X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection,
 "Certificate Select", "Select certificates from the following list
 to get extension information on that certificate", X509SelectionFlag.MultiSelection);

            // Create a new AsnEncodedDataCollection object.
            AsnEncodedDataCollection asncoll = new AsnEncodedDataCollection();
            for (int i = 0; i < scollection.Count;
 i++)
            {
                // Display certificate information.
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Certificate name: {0}", scollection[i].GetName());
                Console.ResetColor();
                // Display extensions information.
                foreach (X509Extension extension in
 scollection[i].Extensions)
                {
                    // Create an AsnEncodedData object using the extensions
 information.
                    AsnEncodedData asndata = new AsnEncodedData(extension.Oid,
 extension.RawData);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Extension type: {0}", extension.Oid.FriendlyName);
                    Console.WriteLine("Oid value: {0}",asndata.Oid.Value);
                    Console.WriteLine("Raw data length: {0} {1}", asndata.RawData.Length,
 Environment.NewLine);
                    Console.ResetColor();
                    Console.WriteLine(asndata.Format(true));
                    Console.WriteLine(Environment.NewLine);
                    // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
                    asncoll.Add(asndata);
                }
                Console.WriteLine(Environment.NewLine);
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll.Count, Environment.NewLine);
            Console.ResetColor();

            store.Close();
            //Create an enumerator for moving through the collection.
            AsnEncodedDataEnumerator asne = 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.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("First AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();

            asne.MoveNext();
            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("Second AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();
            //Return index in the collection to the beginning.
            asne.Reset();
        }
        catch (CryptographicException)
        {
            Console.WriteLine("Information could not be written out for
 this certificate.");
        }
    }
}
#using <System.dll>
#using <System.Security.dll>

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Security::Cryptography::X509Certificates;

int main()
{
   
   //The following example demonstrates the usage of the AsnEncodedData
 classes.
   // Asn encoded data is read from the extensions of an X509 certificate.
   try
   {
      
      // Open the certificate store.
      X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser
 );
      store->Open( static_cast<OpenFlags>(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly)
 );
      X509Certificate2Collection^ collection = dynamic_cast<X509Certificate2Collection^>(store->Certificates);
      X509Certificate2Collection^ fcollection = dynamic_cast<X509Certificate2Collection^>(collection->Find(
 X509FindType::FindByTimeValid, DateTime::Now, false ));
      
      // Select one or more certificates to display extensions information.
      X509Certificate2Collection^ scollection = X509Certificate2UI::SelectFromCollection(fcollection,
 L"Certificate Select",L"Select certificates from the following list
 to get extension information on that certificate",X509SelectionFlag::MultiSelection);
      
      // Create a new AsnEncodedDataCollection object.
      AsnEncodedDataCollection^ asncoll = gcnew AsnEncodedDataCollection;
      for ( int i = 0; i < scollection->Count;
 i++ )
      {
         
         // Display certificate information.
         Console::ForegroundColor = ConsoleColor::Red;
         Console::WriteLine( L"Certificate name: {0}", scollection[i]->GetName()
 );
         Console::ResetColor();
         
         // Display extensions information.
         System::Collections::IEnumerator^ myEnum = scollection[i]->Extensions->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            X509Extension^ extension = safe_cast<X509Extension ^>(myEnum->Current);
            
            // Create an AsnEncodedData object using the extensions
 information.
            AsnEncodedData^ asndata = gcnew AsnEncodedData( extension->Oid,extension->RawData
 );
            Console::ForegroundColor = ConsoleColor::Green;
            Console::WriteLine( L"Extension type: {0}", extension->Oid->FriendlyName
 );
            Console::WriteLine( L"Oid value: {0}", asndata->Oid->Value
 );
            Console::WriteLine( L"Raw data length: {0} {1}", asndata->RawData->Length,
 Environment::NewLine );
            Console::ResetColor();
            Console::WriteLine( asndata->Format(true) );
            Console::WriteLine( Environment::NewLine );
            
            // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
            asncoll->Add( asndata );
         }

         Console::WriteLine( Environment::NewLine );

      }
      Console::ForegroundColor = ConsoleColor::Red;
      Console::WriteLine( L"Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll->Count, Environment::NewLine );
      Console::ResetColor();
      store->Close();
      
      //Create an enumerator for moving through the collection.
      AsnEncodedDataEnumerator^ asne = 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::ForegroundColor = ConsoleColor::Blue;
      Console::WriteLine( L"First AsnEncodedData in the collection:
 {0}", asne->Current->Format(true) );
      Console::ResetColor();
      asne->MoveNext();
      Console::ForegroundColor = ConsoleColor::DarkBlue;
      Console::WriteLine( L"Second AsnEncodedData in the
 collection: {0}", asne->Current->Format(true) );
      Console::ResetColor();
      
      //Return index in the collection to the beginning.
      asne->Reset();
   }
   catch ( CryptographicException^ ) 
   {
      Console::WriteLine( L"Information could not be written out for
 this certificate." );
   }

   return 1;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AsnEncodedData クラス
AsnEncodedData メンバ
System.Security.Cryptography 名前空間

AsnEncodedData コンストラクタ (Byte[])


AsnEncodedData コンストラクタ

AsnEncodedData クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

参照参照

関連項目

AsnEncodedData クラス
AsnEncodedData メンバ
System.Security.Cryptography 名前空間

AsnEncodedData コンストラクタ (String, Byte[])

メモ : このコンストラクタは、.NET Framework version 2.0新しく追加されたものです。

バイト配列使用して、AsnEncodedData クラス新しインスタンス初期化します。

名前空間: System.Security.Cryptography
アセンブリ: System (system.dll 内)
構文構文

使用例使用例

AsnEncodedData クラス使用するコード例次に示します

Imports System
Imports System.Security.Cryptography
Imports System.Security.Cryptography.X509Certificates



Class AsnEncodedDataSample
   Shared msg As String
   Shared Sub Main()
      'The following example demonstrates the usage the AsnEncodedData
 classes.
      ' Asn encoded data is read from the extensions of an X509 certificate.
      Try
         ' Open the certificate store.
         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)
         ' Select one or more certificates to display extensions information.
         Dim scollection As X509Certificate2Collection
 = X509Certificate2UI.SelectFromCollection(fcollection, "Certificate
 Select", "Select certificates from the following list to get extension information on that certificate", X509SelectionFlag.MultiSelection)
         
         ' Create a new AsnEncodedDataCollection object.
         Dim asncoll As New
 AsnEncodedDataCollection()
         Dim i As Integer
         For i = 0 To scollection.Count - 1
            ' Display certificate information.
        msg = "Certificate name: "& scollection(i).GetName()
            MsgBox(msg)

            ' Display extensions information.
            Dim extension As X509Extension
            For Each extension In
  scollection(i).Extensions
               ' Create an AsnEncodedData object using the extensions
 information.
               Dim asndata As New
 AsnEncodedData(extension.Oid, extension.RawData)
           msg = "Extension type: " & extension.Oid.FriendlyName
 & Environment.NewLine & "Oid value: " &
 asndata.Oid.Value _
        & Environment.NewLine & "Raw data length: "
 & asndata.RawData.Length & Environment.NewLine _
        & asndata.Format(True) & Environment.NewLine
               MsgBox(msg)
        
               ' Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
               asncoll.Add(asndata)
            Next extension
         Next i
     msg = "Number of AsnEncodedData items in the collection:
 " & asncoll.Count
         MsgBox(msg)         
         store.Close()

         '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.
     msg = "First AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
    
         
         asne.MoveNext()
     msg = "Second AsnEncodedData in the collection: "
 & asne.Current.Format(True)
     MsgBox(msg)
        
         'Return index in the collection to the beginning.
         asne.Reset()
      Catch 
         MsgBox("Information could not be written out for this
 certificate.")
      End Try
   End Sub 'Main
End Class 'AsnEncodedDataSample
using System;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;

class AsnEncodedDataSample
{
    static void Main()
    {        
        //The following example demonstrates the usage the AsnEncodedData
 classes.
        // Asn encoded data is read from the extensions of an X509 certificate.
        try
        {
            // Open the certificate store.
            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);
            // Select one or more certificates to display extensions
 information.
            X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection,
 "Certificate Select", "Select certificates from the following list
 to get extension information on that certificate", X509SelectionFlag.MultiSelection);

            // Create a new AsnEncodedDataCollection object.
            AsnEncodedDataCollection asncoll = new AsnEncodedDataCollection();
            for (int i = 0; i < scollection.Count;
 i++)
            {
                // Display certificate information.
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Certificate name: {0}", scollection[i].GetName());
                Console.ResetColor();
                // Display extensions information.
                foreach (X509Extension extension in
 scollection[i].Extensions)
                {
                    // Create an AsnEncodedData object using the extensions
 information.
                    AsnEncodedData asndata = new AsnEncodedData(extension.Oid,
 extension.RawData);
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Extension type: {0}", extension.Oid.FriendlyName);
                    Console.WriteLine("Oid value: {0}",asndata.Oid.Value);
                    Console.WriteLine("Raw data length: {0} {1}", asndata.RawData.Length,
 Environment.NewLine);
                    Console.ResetColor();
                    Console.WriteLine(asndata.Format(true));
                    Console.WriteLine(Environment.NewLine);
                    // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
                    asncoll.Add(asndata);
                }
                Console.WriteLine(Environment.NewLine);
            }
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll.Count, Environment.NewLine);
            Console.ResetColor();

            store.Close();
            //Create an enumerator for moving through the collection.
            AsnEncodedDataEnumerator asne = 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.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("First AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();

            asne.MoveNext();
            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("Second AsnEncodedData in the
 collection: {0}", asne.Current.Format(true));
            Console.ResetColor();
            //Return index in the collection to the beginning.
            asne.Reset();
        }
        catch (CryptographicException)
        {
            Console.WriteLine("Information could not be written out for
 this certificate.");
        }
    }
}
#using <System.dll>
#using <System.Security.dll>

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Security::Cryptography::X509Certificates;

int main()
{
   
   //The following example demonstrates the usage of the AsnEncodedData
 classes.
   // Asn encoded data is read from the extensions of an X509 certificate.
   try
   {
      
      // Open the certificate store.
      X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser
 );
      store->Open( static_cast<OpenFlags>(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly)
 );
      X509Certificate2Collection^ collection = dynamic_cast<X509Certificate2Collection^>(store->Certificates);
      X509Certificate2Collection^ fcollection = dynamic_cast<X509Certificate2Collection^>(collection->Find(
 X509FindType::FindByTimeValid, DateTime::Now, false ));
      
      // Select one or more certificates to display extensions information.
      X509Certificate2Collection^ scollection = X509Certificate2UI::SelectFromCollection(fcollection,
 L"Certificate Select",L"Select certificates from the following list
 to get extension information on that certificate",X509SelectionFlag::MultiSelection);
      
      // Create a new AsnEncodedDataCollection object.
      AsnEncodedDataCollection^ asncoll = gcnew AsnEncodedDataCollection;
      for ( int i = 0; i < scollection->Count;
 i++ )
      {
         
         // Display certificate information.
         Console::ForegroundColor = ConsoleColor::Red;
         Console::WriteLine( L"Certificate name: {0}", scollection[i]->GetName()
 );
         Console::ResetColor();
         
         // Display extensions information.
         System::Collections::IEnumerator^ myEnum = scollection[i]->Extensions->GetEnumerator();
         while ( myEnum->MoveNext() )
         {
            X509Extension^ extension = safe_cast<X509Extension ^>(myEnum->Current);
            
            // Create an AsnEncodedData object using the extensions
 information.
            AsnEncodedData^ asndata = gcnew AsnEncodedData( extension->Oid,extension->RawData
 );
            Console::ForegroundColor = ConsoleColor::Green;
            Console::WriteLine( L"Extension type: {0}", extension->Oid->FriendlyName
 );
            Console::WriteLine( L"Oid value: {0}", asndata->Oid->Value
 );
            Console::WriteLine( L"Raw data length: {0} {1}", asndata->RawData->Length,
 Environment::NewLine );
            Console::ResetColor();
            Console::WriteLine( asndata->Format(true) );
            Console::WriteLine( Environment::NewLine );
            
            // Add the AsnEncodedData object to the AsnEncodedDataCollection
 object.
            asncoll->Add( asndata );
         }

         Console::WriteLine( Environment::NewLine );

      }
      Console::ForegroundColor = ConsoleColor::Red;
      Console::WriteLine( L"Number of AsnEncodedData items in
 the collection: {0} {1}", asncoll->Count, Environment::NewLine );
      Console::ResetColor();
      store->Close();
      
      //Create an enumerator for moving through the collection.
      AsnEncodedDataEnumerator^ asne = 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::ForegroundColor = ConsoleColor::Blue;
      Console::WriteLine( L"First AsnEncodedData in the collection:
 {0}", asne->Current->Format(true) );
      Console::ResetColor();
      asne->MoveNext();
      Console::ForegroundColor = ConsoleColor::DarkBlue;
      Console::WriteLine( L"Second AsnEncodedData in the
 collection: {0}", asne->Current->Format(true) );
      Console::ResetColor();
      
      //Return index in the collection to the beginning.
      asne->Reset();
   }
   catch ( CryptographicException^ ) 
   {
      Console::WriteLine( L"Information could not be written out for
 this certificate." );
   }

   return 1;
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
AsnEncodedData クラス
AsnEncodedData メンバ
System.Security.Cryptography 名前空間

AsnEncodedData プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

AsnEncodedData クラス
System.Security.Cryptography 名前空間

AsnEncodedData メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

AsnEncodedData クラス
System.Security.Cryptography 名前空間

AsnEncodedData メンバ

ASN.1 (Abstract Syntax Notation One) でエンコードされたデータ表します

AsnEncodedData データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
プロテクト コンストラクタプロテクト コンストラクタ
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

AsnEncodedData クラス
System.Security.Cryptography 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「AsnEncodedData」の関連用語

AsnEncodedDataのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



AsnEncodedDataのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS