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



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

辞書ショートカット

すべての辞書の索引

「X509FindType 列挙体」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS