X509FindType 列挙体
アセンブリ: System (system.dll 内)

Public Enumeration X509FindType

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


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

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- X509FindType 列挙体のページへのリンク