X509Chain クラス
アセンブリ: System (system.dll 内)


X509Chain オブジェクトには、ChainStatus と呼ばれるグローバルなエラー状態があります。このエラー状態は、証明書の検証に使用する必要があります。証明書の検証を管理する規則は複雑ですが、関係する 1 つ以上の要素のエラー状態を無視すると、検証ロジックを単純化しすぎることになります。グローバルなエラー状態では、チェーン内の各要素の状態が考慮されます。

現在のユーザーの個人用証明書ストアを開いて、証明書を選択できるようにし、証明書および証明書チェーン情報をコンソールに出力するコード例を次に示します。出力は、選択した証明書に依存します。
using System; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; using System.IO; class TestX509Chain { static void Main(string[] args) { //Create new X509 store from local certificate store. X509Store store = new X509Store("MY", StoreLocation.CurrentUser); store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite); //Output store information. Console.WriteLine ("Store Information"); Console.WriteLine ("Number of certificates in the store: {0}", store.Certificates.Count); Console.WriteLine ("Store location: {0}", store.Location); Console.WriteLine ("Store name: {0} {1}", store.Name, Environment.NewLine); //Put certificates from the store into a collection so user can select one. X509Certificate2Collection fcollection = (X509Certificate2Collection)store.Certificates; X509Certificate2Collection collection = X509Certificate2UI.SelectFromCollection(fcollection, "Select an X509 Certificate", "Choose a certificate to examine.", X509SelectionFlag.SingleSelection); X509Certificate2 certificate = collection[0]; X509Certificate2UI.DisplayCertificate(certificate); //Output chain information of the selected certificate. X509Chain ch = new X509Chain(); ch.Build (certificate); Console.WriteLine ("Chain Information"); ch.ChainPolicy.RevocationMode = X509RevocationMode.Online; Console.WriteLine ("Chain revocation flag: {0}", ch.ChainPolicy.RevocationFlag); Console.WriteLine ("Chain revocation mode: {0}", ch.ChainPolicy.RevocationMode); Console.WriteLine ("Chain verification flag: {0}", ch.ChainPolicy.VerificationFlags); Console.WriteLine ("Chain verification time: {0}", ch.ChainPolicy.VerificationTime); Console.WriteLine ("Chain status length: {0}", ch.ChainStatus.Length); Console.WriteLine ("Chain application policy count: {0}", ch.ChainPolicy.ApplicationPolicy.Count); Console.WriteLine ("Chain certificate policy count: {0} {1}", ch.ChainPolicy.CertificatePolicy.Count, Environment.NewLine); //Output chain element information. Console.WriteLine ("Chain Element Information"); Console.WriteLine ("Number of chain elements: {0}", ch.ChainElements.Count); Console.WriteLine ("Chain elements synchronized? {0} {1}", ch.ChainElements.IsSynchronized, Environment.NewLine); foreach (X509ChainElement element in ch.ChainElements) { Console.WriteLine ("Element issuer name: {0}", element.Certificate.Issuer); Console.WriteLine ("Element certificate valid until: {0}", element.Certificate.NotAfter); Console.WriteLine ("Element certificate is valid: {0}", element.Certificate.Verify ()); Console.WriteLine ("Element error status length: {0}", element.ChainElementStatus.Length); Console.WriteLine ("Element information: {0}", element.Information); Console.WriteLine ("Number of element extensions: {0}{1}", element.Certificate.Extensions.Count, Environment.NewLine); if (ch.ChainStatus.Length > 1) { for (int index = 0; index < element.ChainElementStatus.Length; index++) { Console.WriteLine (element.ChainElementStatus[index].Status); Console.WriteLine (element.ChainElementStatus[index].StatusInformation); } } } store.Close(); } }

System.Security.Cryptography.X509Certificates.X509Chain


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からX509Chain クラスを検索する場合は、下記のリンクをクリックしてください。

- X509Chain クラスのページへのリンク