X509FindType 列挙体とは? わかりやすく解説

X509FindType 列挙体

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

Find メソッドで検索する値の種類を指定します。

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

public enum X509FindType
public enum class X509FindType
public enum X509FindType
public enum X509FindType
メンバメンバ
 メンバ名説明
FindByApplicationPolicyFind の findValue パラメータは、アプリケーション ポリシーの表示名または証明書のオブジェクト識別子 (Oid) を表す文字列であることが必要です。たとえば、"Encrypting File System" や "1.3.6.1.4.1.311.10.3.4" などを使用できます。ローカライズを予定しているアプリケーションの場合、表示名がローカライズされることを考慮し、OID 値を使用する必要があります。 
FindByCertificatePolicyFind の findValue パラメータは、証明書ポリシーの表示名またはオブジェクト識別子 (Oid) を表す文字列であることが必要です。できるだけ、"1.3.6.1.4.1.311.10.3.4" などの OID を使用することをお勧めします。ローカライズを予定しているアプリケーションの場合、表示名がローカライズされることを考慮し、OID を使用する必要があります。 
FindByExtensionFind の findValue パラメータは、検索する拡張機能を表す文字列であることが必要です。Find メソッドで特定の拡張機能を持つすべての証明書を検索する場合は、一致条件にオブジェクト識別子 (OID) を使用するのが一般的です。 
FindByIssuerDistinguishedNameFind メソッドの findValue パラメータは、証明書発行者の識別名を表す文字列であることが必要です。これは、FindByIssuerName 列挙値を使用した場合よりも、具体的な検索になります。Find メソッドに FindByIssuerDistinguishedName 値を使用した場合、識別名全体について、大文字と小文字を区別しない文字列比較が実行されます。発行者名での検索は、これよりも条件があいまいになります。 
FindByIssuerNameFind メソッドの findValue パラメータは、証明書の発行者名を表す文字列であることが必要です。これは、FindByIssuerDistinguishedName 列挙値を使用した場合よりも、条件があいまいになります。Find メソッドに FindByIssuerName 値を使用した場合、指定した値に基づいて、大文字と小文字を区別しない文字列比較が実行されます。たとえば、Find メソッドに "MyCA" を指定した場合、発行者の他の値に関係なく、発行者名にこの文字列が使われている、すべての証明書が検索されます。 
FindByKeyUsageFind のfindValue パラメータには、キーの使用目的を表す文字列を指定するか、要求されたキー使用目的をすべて満たしたビット マスクを整数で指定する必要があります。文字列値の場合、同時に指定できるキーの使用目的は 1 つだけですが、Find メソッドで検索範囲を段階的に狭めてゆくことにより、要求した使用目的を論理積的に得ることもできます。たとえば、findValue パラメータには、"KeyEncipherment" または整数値 (0x30 は "KeyEncipherment" および "DataEncipherment" に相当) を設定できるほか、X509KeyUsageFlags 列挙型の値を使用することもできます。 
FindBySerialNumberFind の findValue パラメータには、証明書のシリアル番号を、UI 上の表示文字列で指定する必要があります。シリアル番号は整数であるため、逆順で指定することが必要です。 
FindBySubjectDistinguishedNameFind メソッドの findValue パラメータは、証明書サブジェクトの識別名を表す文字列であることが必要です。これは、FindBySubjectName 列挙値を使用した場合よりも、具体的な検索になります。Find メソッドに FindBySubjectDistinguishedName 値を使用した場合、識別名全体について、大文字と小文字を区別しない文字列比較が実行されます。サブジェクト名での検索は、これよりも条件があいまいになります。 
FindBySubjectKeyIdentifierFind の findValue パラメータは、サブジェクトのキー識別子 ("F3E815D45E83B8477B9284113C64EF208E897112" などの 16 進数で表される) を UI 上の文字列で指定する必要があります。 
FindBySubjectNameFind メソッドの findValue パラメータは、証明書のサブジェクト名を表す文字列であることが必要です。これは、FindBySubjectDistinguishedName 列挙値を使用した場合よりも、条件があいまいになります。Find メソッドに FindBySubjectName 値を使用した場合、指定した値に基づいて、大文字と小文字を区別しない文字列比較が実行されます。たとえば、Find メソッドに "MyCert" を指定した場合、サブジェクトの他の値に関係なく、サブジェクト名にこの文字列が使われている、すべての証明書が検索されます。識別名での検索の方が、より具体的な条件になります。 
FindByTemplateNameFind の findValue パラメータは、"ClientAuth" など、証明書のテンプレート名を表す文字列であることが必要です。テンプレート名は、証明書の使用目的を指定する、X509 バージョン 3 の拡張機能です。 
FindByThumbprintFind メソッドの findValue パラメータは、証明書のサムプリントを表す文字列であることが必要です。 
FindByTimeExpiredFind の findValue パラメータは、Now などを使用して、DateTime 値を現地時間で指定する必要があります。なお、FindByTimeValid、FindByTimeNotYetValid、および FindByTimeExpired の和集合には、すべての証明書が包含されます。 
FindByTimeNotYetValidFind の findValue パラメータは、Now などを使用して、DateTime 値を現地時間で指定する必要があります。なお、FindByTimeValid、FindByTimeNotYetValid、および FindByTimeExpired の和集合には、すべての証明書が包含されます。 
FindByTimeValidFind の findValue パラメータは、Now などを使用して、DateTime 値を現地時間で指定する必要があります。なお、FindByTimeValid、FindByTimeNotYetValid、および FindByTimeExpired の和集合には、すべての証明書が包含されます。 
解説解説

この値により、Find メソッドの検索条件を指定します。たとえば、サブジェクト名、サムプリント、シリアル番号などの条件で、X509Certificate2 コレクションを検索できます。

使用例使用例

現在のユーザーの個人用証明書ストアを開いて有効な証明書だけを検索し、ユーザーが証明書を選択できるようにして、証明書情報をコンソールに出力する例を次に示します。出力は、選択した証明書に依存します。

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

class CertSelect
{
    static void Main()
    {
        try
        {
            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)
                {
                    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();
                }
            store.Close();
            }
        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::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." );
   }

}

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Security.Cryptography.X509Certificates 名前空間



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「X509FindType 列挙体」の関連用語

X509FindType 列挙体のお隣キーワード
検索ランキング

   

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



X509FindType 列挙体のページの著作権

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

©2026 GRAS Group, Inc.RSS