X509Certificate2Collection X509Certificate2Collection X509Certificate2Collection X509Certificate2Collection Class

定義

X509Certificate2 オブジェクトのコレクションを表します。 Represents a collection of X509Certificate2 objects. このクラスは継承できません。 This class cannot be inherited.

public ref class X509Certificate2Collection : System::Security::Cryptography::X509Certificates::X509CertificateCollection
public class X509Certificate2Collection : System.Security.Cryptography.X509Certificates.X509CertificateCollection
type X509Certificate2Collection = class
    inherit X509CertificateCollection
Public Class X509Certificate2Collection
Inherits X509CertificateCollection
継承

次のコード例は、現在のユーザーの個人証明書ストアを開いて、有効な証明書のみを選択、ユーザーは、証明書を選択できます、およびコンソールに証明書と証明書チェーンの情報を書き込みますを。The following code example opens the current user's personal certificate store, selects only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. 出力は、ユーザーが選択した証明書に依存します。The output depends on the certificate the user selects.

#using <System.dll>
#using <System.Security.dll>

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Security::Permissions;
using namespace System::IO;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
   try
   {
      X509Store ^ store = gcnew X509Store( "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 ));
      X509Certificate2Collection ^ scollection = X509Certificate2UI::SelectFromCollection(fcollection, "Test Certificate Select","Select a certificate from the following list to get information on that certificate",X509SelectionFlag::MultiSelection);
      Console::WriteLine( "Number of certificates: {0}{1}", scollection->Count, Environment::NewLine );
      System::Collections::IEnumerator^ myEnum = scollection->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         X509Certificate2 ^ x509 = safe_cast<X509Certificate2 ^>(myEnum->Current);
         array<Byte>^rawdata = x509->RawData;
         Console::WriteLine( "Content Type: {0}{1}", X509Certificate2::GetCertContentType( rawdata ), Environment::NewLine );
         Console::WriteLine( "Friendly Name: {0}{1}", x509->FriendlyName, Environment::NewLine );
         Console::WriteLine( "Certificate Verified?: {0}{1}", x509->Verify(), Environment::NewLine );
         Console::WriteLine( "Simple Name: {0}{1}", x509->GetNameInfo( X509NameType::SimpleName, true ), Environment::NewLine );
         Console::WriteLine( "Signature Algorithm: {0}{1}", x509->SignatureAlgorithm->FriendlyName, Environment::NewLine );
         Console::WriteLine( "Private Key: {0}{1}", x509->PrivateKey->ToXmlString( false ), Environment::NewLine );
         Console::WriteLine( "Public Key: {0}{1}", x509->PublicKey->Key->ToXmlString( false ), Environment::NewLine );
         Console::WriteLine( "Certificate Archived?: {0}{1}", x509->Archived, Environment::NewLine );
         Console::WriteLine( "Length of Raw Data: {0}{1}", x509->RawData->Length, Environment::NewLine );
         x509->Reset();
      }
      store->Close();
   }
   catch ( CryptographicException^ ) 
   {
      Console::WriteLine( "Information could not be written out for this certificate." );
   }

}

using System;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.IO;
using System.Security.Cryptography.X509Certificates;

class CertSelect
{
    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, "Test Certificate Select","Select a certificate from the following list to get information on that certificate",X509SelectionFlag.MultiSelection);
        Console.WriteLine("Number of certificates: {0}{1}",scollection.Count,Environment.NewLine);

        foreach (X509Certificate2 x509 in scollection)
        {
            try
            {
                byte[] rawdata = x509.RawData;
                Console.WriteLine("Content Type: {0}{1}",X509Certificate2.GetCertContentType(rawdata),Environment.NewLine);
                Console.WriteLine("Friendly Name: {0}{1}",x509.FriendlyName,Environment.NewLine);
                Console.WriteLine("Certificate Verified?: {0}{1}",x509.Verify(),Environment.NewLine);
                Console.WriteLine("Simple Name: {0}{1}",x509.GetNameInfo(X509NameType.SimpleName,true),Environment.NewLine);
                Console.WriteLine("Signature Algorithm: {0}{1}",x509.SignatureAlgorithm.FriendlyName,Environment.NewLine);
                Console.WriteLine("Private Key: {0}{1}",x509.PrivateKey.ToXmlString(false),Environment.NewLine);
                Console.WriteLine("Public Key: {0}{1}",x509.PublicKey.Key.ToXmlString(false),Environment.NewLine);
                Console.WriteLine("Certificate Archived?: {0}{1}",x509.Archived,Environment.NewLine);
                Console.WriteLine("Length of Raw Data: {0}{1}",x509.RawData.Length,Environment.NewLine);
                X509Certificate2UI.DisplayCertificate(x509);
                x509.Reset();
            }
            catch (CryptographicException)
            {
                Console.WriteLine("Information could not be written out for this certificate.");
            }
        }
        store.Close();
    }
}
Imports System
Imports System.Security.Cryptography
Imports System.Security.Permissions
Imports System.IO
Imports System.Security.Cryptography.X509Certificates

Class CertSelect

    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, "Test Certificate Select", "Select a certificate from the following list to get information on that certificate", X509SelectionFlag.MultiSelection)
        Console.WriteLine("Number of certificates: {0}{1}", scollection.Count, Environment.NewLine)
         
        For Each x509 As X509Certificate2 In scollection
            Try
                Dim rawdata As Byte() = x509.RawData
                Console.WriteLine("Content Type: {0}{1}", X509Certificate2.GetCertContentType(rawdata), Environment.NewLine)
                Console.WriteLine("Friendly Name: {0}{1}", x509.FriendlyName, Environment.NewLine)
                Console.WriteLine("Certificate Verified?: {0}{1}", x509.Verify(), Environment.NewLine)
                Console.WriteLine("Simple Name: {0}{1}", x509.GetNameInfo(X509NameType.SimpleName, True), Environment.NewLine)
                Console.WriteLine("Signature Algorithm: {0}{1}", x509.SignatureAlgorithm.FriendlyName, Environment.NewLine)
                Console.WriteLine("Private Key: {0}{1}", x509.PrivateKey.ToXmlString(False), Environment.NewLine)
                Console.WriteLine("Public Key: {0}{1}", x509.PublicKey.Key.ToXmlString(False), Environment.NewLine)
                Console.WriteLine("Certificate Archived?: {0}{1}", x509.Archived, Environment.NewLine)
                Console.WriteLine("Length of Raw Data: {0}{1}", x509.RawData.Length, Environment.NewLine)
                X509Certificate2UI.DisplayCertificate(x509)
                x509.Reset()         
             Catch cExcept As CryptographicException
                 Console.WriteLine("Information could not be written out for this certificate.")
             End Try
        Next x509

        store.Close()
    End Sub
End Class

注釈

ときに、X509Certificate2ストアを開くと、結果がによって表される、X509Certificate2Collectionオブジェクト。When an X509Certificate2 store is opened, the result is represented by an X509Certificate2Collection object. 場合は、Cryptographic API、アンマネージ コンストラクトに慣れて考えることができます、X509Certificate2CollectionのメモリのストアとしてX509Certificate2オブジェクト。If you are familiar with the unmanaged Cryptographic API constructs, you can think of an X509Certificate2Collection as a memory store of X509Certificate2 objects.

コンストラクター

X509Certificate2Collection() X509Certificate2Collection() X509Certificate2Collection() X509Certificate2Collection()

X509Certificate2Collection 情報を指定せずに、X509Certificate2 クラスの新しいインスタンスを初期化します。 Initializes a new instance of the X509Certificate2Collection class without any X509Certificate2 information.

X509Certificate2Collection(X509Certificate2) X509Certificate2Collection(X509Certificate2) X509Certificate2Collection(X509Certificate2) X509Certificate2Collection(X509Certificate2)

X509Certificate2Collection オブジェクトを使用して X509Certificate2 クラスの新しいインスタンスを 初期化します。 Initializes a new instance of the X509Certificate2Collection class using an X509Certificate2 object.

X509Certificate2Collection(X509Certificate2Collection) X509Certificate2Collection(X509Certificate2Collection) X509Certificate2Collection(X509Certificate2Collection) X509Certificate2Collection(X509Certificate2Collection)

証明書コレクションを指定して、X509Certificate2Collection クラスの新しいインスタンスを初期化します。 Initializes a new instance of the X509Certificate2Collection class using the specified certificate collection.

X509Certificate2Collection(X509Certificate2[]) X509Certificate2Collection(X509Certificate2[]) X509Certificate2Collection(X509Certificate2[]) X509Certificate2Collection(X509Certificate2[])

X509Certificate2Collection オブジェクトの配列を使用して、X509Certificate2 クラスの新しいインスタンスを初期化します。 Initializes a new instance of the X509Certificate2Collection class using an array of X509Certificate2 objects.

プロパティ

Capacity Capacity Capacity Capacity

CollectionBase に格納できる要素の数を取得または設定します。 Gets or sets the number of elements that the CollectionBase can contain.

(Inherited from CollectionBase)
Count Count Count Count Inherited from X509CertificateCollection
ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized Inherited from X509CertificateCollection
ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot Inherited from X509CertificateCollection
IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize Inherited from X509CertificateCollection
IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly Inherited from X509CertificateCollection
IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] Inherited from X509CertificateCollection
InnerList InnerList InnerList InnerList

ArrayList インスタンス内の要素のリストを格納する CollectionBase を取得します。 Gets an ArrayList containing the list of elements in the CollectionBase instance.

(Inherited from CollectionBase)
Item[Int32] Item[Int32] Item[Int32] Item[Int32]

指定したインデックスにある要素を取得または設定します。 Gets or sets the element at the specified index.

List List List List

IList インスタンス内の要素のリストを格納する CollectionBase を取得します。 Gets an IList containing the list of elements in the CollectionBase instance.

(Inherited from CollectionBase)

方法

Add(X509Certificate) Add(X509Certificate) Add(X509Certificate) Add(X509Certificate)

X509Certificate を指定された値と共に現在の X509CertificateCollection に追加します。 Adds an X509Certificate with the specified value to the current X509CertificateCollection.

(Inherited from X509CertificateCollection)
Add(X509Certificate2) Add(X509Certificate2) Add(X509Certificate2) Add(X509Certificate2)

X509Certificate2Collection の末尾にオブジェクトを追加します。 Adds an object to the end of the X509Certificate2Collection.

AddRange(X509Certificate2Collection) AddRange(X509Certificate2Collection) AddRange(X509Certificate2Collection) AddRange(X509Certificate2Collection)

X509Certificate2 オブジェクト内の複数の X509Certificate2Collection オブジェクトを別の X509Certificate2Collection オブジェクトに追加します。 Adds multiple X509Certificate2 objects in an X509Certificate2Collection object to another X509Certificate2Collection object.

AddRange(X509Certificate2[]) AddRange(X509Certificate2[]) AddRange(X509Certificate2[]) AddRange(X509Certificate2[])

配列内の複数の X509Certificate2 オブジェクトを X509Certificate2Collection オブジェクトに追加します。 Adds multiple X509Certificate2 objects in an array to the X509Certificate2Collection object.

AddRange(X509CertificateCollection) AddRange(X509CertificateCollection) AddRange(X509CertificateCollection) AddRange(X509CertificateCollection)

指定された X509CertificateCollection の要素を現在の X509CertificateCollection の末尾にコピーします。 Copies the elements of the specified X509CertificateCollection to the end of the current X509CertificateCollection.

(Inherited from X509CertificateCollection)
AddRange(X509Certificate[]) AddRange(X509Certificate[]) AddRange(X509Certificate[]) AddRange(X509Certificate[])

X509Certificate の配列の要素を現在の X509CertificateCollection の末尾にコピーします。 Copies the elements of an array of type X509Certificate to the end of the current X509CertificateCollection.

(Inherited from X509CertificateCollection)
Clear() Clear() Clear() Clear() Inherited from X509CertificateCollection
Contains(X509Certificate) Contains(X509Certificate) Contains(X509Certificate) Contains(X509Certificate)

指定した X509Certificate が 現在の X509CertificateCollection に格納されているかどうかを示す値を取得します。 Gets a value indicating whether the current X509CertificateCollection contains the specified X509Certificate.

(Inherited from X509CertificateCollection)
Contains(X509Certificate2) Contains(X509Certificate2) Contains(X509Certificate2) Contains(X509Certificate2)

X509Certificate2Collection オブジェクトに特定の証明書が格納されているかどうかを確認します。 Determines whether the X509Certificate2Collection object contains a specific certificate.

CopyTo(X509Certificate[], Int32) CopyTo(X509Certificate[], Int32) CopyTo(X509Certificate[], Int32) CopyTo(X509Certificate[], Int32)

現在の X509CertificateCollectionX509Certificate 値を 1 次元の Array インスタンスの指定したインデックス位置にコピーします。 Copies the X509Certificate values in the current X509CertificateCollection to a one-dimensional Array instance at the specified index.

(Inherited from X509CertificateCollection)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

指定したオブジェクトが、現在のオブジェクトと等しいかどうかを判断します。 Determines whether the specified object is equal to the current object.

(Inherited from Object)
Export(X509ContentType) Export(X509ContentType) Export(X509ContentType) Export(X509ContentType)

X.509 証明書情報をバイト配列にエクスポートします。 Exports X.509 certificate information into a byte array.

Export(X509ContentType, String) Export(X509ContentType, String) Export(X509ContentType, String) Export(X509ContentType, String)

パスワードを使用して X.509 証明書情報をバイト配列にエクスポートします。 Exports X.509 certificate information into a byte array using a password.

Find(X509FindType, Object, Boolean) Find(X509FindType, Object, Boolean) Find(X509FindType, Object, Boolean) Find(X509FindType, Object, Boolean)

X509Certificate2Collection 列挙体および findValue オブジェクトで指定された検索条件を使用して、X509FindType オブジェクトを検索します。 Searches an X509Certificate2Collection object using the search criteria specified by the X509FindType enumeration and the findValue object.

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

X509Certificate2Collection オブジェクトを反復処理できる列挙子を返します。 Returns an enumerator that can iterate through a X509Certificate2Collection object.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

現在の X509CertificateCollection に含まれるすべての値に基づいてハッシュ値をビルドします。 Builds a hash value based on all values contained in the current X509CertificateCollection.

(Inherited from X509CertificateCollection)
GetType() GetType() GetType() GetType()

現在のインスタンスの Type を取得します。 Gets the Type of the current instance.

(Inherited from Object)
Import(Byte[]) Import(Byte[]) Import(Byte[]) Import(Byte[])

証明書をバイト配列形式で X509Certificate2Collection オブジェクトにインポートします。 Imports a certificate in the form of a byte array into a X509Certificate2Collection object.

Import(Byte[], String, X509KeyStorageFlags) Import(Byte[], String, X509KeyStorageFlags) Import(Byte[], String, X509KeyStorageFlags) Import(Byte[], String, X509KeyStorageFlags)

証明書にアクセスするためのパスワードを必要とするバイト配列形式で証明書を X509Certificate2Collection オブジェクトにインポートします。 Imports a certificate, in the form of a byte array that requires a password to access the certificate, into a X509Certificate2Collection object.

Import(String) Import(String) Import(String) Import(String)

証明書ファイルを X509Certificate2Collection オブジェクトにインポートします。 Imports a certificate file into a X509Certificate2Collection object.

Import(String, String, X509KeyStorageFlags) Import(String, String, X509KeyStorageFlags) Import(String, String, X509KeyStorageFlags) Import(String, String, X509KeyStorageFlags)

パスワードが必要な証明書ファイルを X509Certificate2Collection オブジェクトにインポートします。 Imports a certificate file that requires a password into a X509Certificate2Collection object.

IndexOf(X509Certificate) IndexOf(X509Certificate) IndexOf(X509Certificate) IndexOf(X509Certificate)

現在の X509CertificateCollection 内の指定した X509Certificate のインデックスを返します。 Returns the index of the specified X509Certificate in the current X509CertificateCollection.

(Inherited from X509CertificateCollection)
Insert(Int32, X509Certificate) Insert(Int32, X509Certificate) Insert(Int32, X509Certificate) Insert(Int32, X509Certificate)

X509Certificate を現在の X509CertificateCollection 内の指定したインデックス位置に挿入します。 Inserts a X509Certificate into the current X509CertificateCollection at the specified index.

(Inherited from X509CertificateCollection)
Insert(Int32, X509Certificate2) Insert(Int32, X509Certificate2) Insert(Int32, X509Certificate2) Insert(Int32, X509Certificate2)

X509Certificate2Collection オブジェクト内の指定したインデックス位置にオブジェクトを挿入します。 Inserts an object into the X509Certificate2Collection object at the specified index.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

現在の Object の簡易コピーを作成します。 Creates a shallow copy of the current Object.

(Inherited from Object)
OnClear() OnClear() OnClear() OnClear()

CollectionBase インスタンスの内容を消去しているときに、追加のカスタム プロセスを実行します。 Performs additional custom processes when clearing the contents of the CollectionBase instance.

(Inherited from CollectionBase)
OnClearComplete() OnClearComplete() OnClearComplete() OnClearComplete()

CollectionBase インスタンスの内容を消去した後に、追加のカスタム プロセスを実行します。 Performs additional custom processes after clearing the contents of the CollectionBase instance.

(Inherited from CollectionBase)
OnInsert(Int32, Object) OnInsert(Int32, Object) OnInsert(Int32, Object) OnInsert(Int32, Object)

CollectionBase インスタンスに新しい要素を挿入する前に、追加のカスタム プロセスを実行します。 Performs additional custom processes before inserting a new element into the CollectionBase instance.

(Inherited from CollectionBase)
OnInsertComplete(Int32, Object) OnInsertComplete(Int32, Object) OnInsertComplete(Int32, Object) OnInsertComplete(Int32, Object)

CollectionBase インスタンスに新しい要素を挿入した後に、追加のカスタム プロセスを実行します。 Performs additional custom processes after inserting a new element into the CollectionBase instance.

(Inherited from CollectionBase)
OnRemove(Int32, Object) OnRemove(Int32, Object) OnRemove(Int32, Object) OnRemove(Int32, Object)

CollectionBase インスタンスから要素を削除するときに、追加のカスタム プロセスを実行します。 Performs additional custom processes when removing an element from the CollectionBase instance.

(Inherited from CollectionBase)
OnRemoveComplete(Int32, Object) OnRemoveComplete(Int32, Object) OnRemoveComplete(Int32, Object) OnRemoveComplete(Int32, Object)

CollectionBase インスタンスから要素を削除した後に、追加のカスタム プロセスを実行します。 Performs additional custom processes after removing an element from the CollectionBase instance.

(Inherited from CollectionBase)
OnSet(Int32, Object, Object) OnSet(Int32, Object, Object) OnSet(Int32, Object, Object) OnSet(Int32, Object, Object)

CollectionBase インスタンスに値を設定する前に、追加のカスタム プロセスを実行します。 Performs additional custom processes before setting a value in the CollectionBase instance.

(Inherited from CollectionBase)
OnSetComplete(Int32, Object, Object) OnSetComplete(Int32, Object, Object) OnSetComplete(Int32, Object, Object) OnSetComplete(Int32, Object, Object)

CollectionBase インスタンスに値を設定した後に、追加のカスタム プロセスを実行します。 Performs additional custom processes after setting a value in the CollectionBase instance.

(Inherited from CollectionBase)
OnValidate(Object) OnValidate(Object) OnValidate(Object) OnValidate(Object) Inherited from X509CertificateCollection
Remove(X509Certificate) Remove(X509Certificate) Remove(X509Certificate) Remove(X509Certificate)

特定の X509Certificate を現在の X509CertificateCollection から削除します。 Removes a specific X509Certificate from the current X509CertificateCollection.

(Inherited from X509CertificateCollection)
Remove(X509Certificate2) Remove(X509Certificate2) Remove(X509Certificate2) Remove(X509Certificate2)

X509Certificate2Collection オブジェクト内で最初に見つかった証明書を削除します。 Removes the first occurrence of a certificate from the X509Certificate2Collection object.

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) Inherited from X509CertificateCollection
RemoveRange(X509Certificate2Collection) RemoveRange(X509Certificate2Collection) RemoveRange(X509Certificate2Collection) RemoveRange(X509Certificate2Collection)

X509Certificate2 オブジェクト内の複数の X509Certificate2Collection オブジェクトを別の X509Certificate2Collection オブジェクトから削除します。 Removes multiple X509Certificate2 objects in an X509Certificate2Collection object from another X509Certificate2Collection object.

RemoveRange(X509Certificate2[]) RemoveRange(X509Certificate2[]) RemoveRange(X509Certificate2[]) RemoveRange(X509Certificate2[])

配列内の複数の X509Certificate2 オブジェクトを X509Certificate2Collection オブジェクトから削除します。 Removes multiple X509Certificate2 objects in an array from an X509Certificate2Collection object.

ToString() ToString() ToString() ToString()

現在のオブジェクトを表す文字列を返します。 Returns a string that represents the current object.

(Inherited from Object)

明示的なインターフェイスの実装

ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) ICollection.CopyTo(Array, Int32) Inherited from X509CertificateCollection
IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() Inherited from X509CertificateCollection
IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object) Inherited from X509CertificateCollection
IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) Inherited from X509CertificateCollection
IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) Inherited from X509CertificateCollection
IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) Inherited from X509CertificateCollection
IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) Inherited from X509CertificateCollection

適用対象