X509SubjectKeyIdentifierExtension Class
.NET Framework 2.0
Note: This class is new in the .NET Framework version 2.0.
Defines a string that identifies a certificate's subject key identifier (SKI). This class cannot be inherited.
Namespace: System.Security.Cryptography.X509Certificates
Assembly: System (in system.dll)
Assembly: System (in system.dll)
The following code example demonstrates how to open a user’s personal certificate store and display information about each certificate in the store. This example uses the X509SubjectKeyIdentifierExtension class to display the information.
using System; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; public class CertSelect { public static void Main() { try { X509Store store = new X509Store("MY", StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates; for (int i = 0; i < collection.Count; i++) { foreach (X509Extension extension in collection[i].Extensions) { Console.WriteLine(extension.Oid.FriendlyName + "(" + extension.Oid.Value + ")"); if (extension.Oid.FriendlyName == "Key Usage") { X509KeyUsageExtension ext = (X509KeyUsageExtension)extension; Console.WriteLine(ext.KeyUsages); } if (extension.Oid.FriendlyName == "Basic Constraints") { X509BasicConstraintsExtension ext = (X509BasicConstraintsExtension)extension; Console.WriteLine(ext.CertificateAuthority); Console.WriteLine(ext.HasPathLengthConstraint); Console.WriteLine(ext.PathLengthConstraint); } if (extension.Oid.FriendlyName == "Subject Key Identifier") { X509SubjectKeyIdentifierExtension ext = (X509SubjectKeyIdentifierExtension)extension; Console.WriteLine(ext.SubjectKeyIdentifier); } if (extension.Oid.FriendlyName == "Enhanced Key Usage") { X509EnhancedKeyUsageExtension ext = (X509EnhancedKeyUsageExtension)extension; OidCollection oids = ext.EnhancedKeyUsages; foreach (Oid oid in oids) { Console.WriteLine(oid.FriendlyName + "(" + oid.Value + ")"); } } } } store.Close(); } catch (CryptographicException) { Console.WriteLine("Information could not be written out for this certificate."); } } }
System.Object
System.Security.Cryptography.AsnEncodedData
System.Security.Cryptography.X509Certificates.X509Extension
System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension
System.Security.Cryptography.AsnEncodedData
System.Security.Cryptography.X509Certificates.X509Extension
System.Security.Cryptography.X509Certificates.X509SubjectKeyIdentifierExtension
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
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.