X509EnhancedKeyUsageExtension Class
Defines the collection of object identifiers (OIDs) that indicates the applications that use the key. This class cannot be inherited.
System.Security.Cryptography.AsnEncodedData
System.Security.Cryptography.X509Certificates.X509Extension
System.Security.Cryptography.X509Certificates.X509EnhancedKeyUsageExtension
Assembly: System (in System.dll)
The X509EnhancedKeyUsageExtension type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | X509EnhancedKeyUsageExtension | Initializes a new instance of the X509EnhancedKeyUsageExtension class. |
![]() | X509EnhancedKeyUsageExtension(AsnEncodedData, Boolean) | Initializes a new instance of the X509EnhancedKeyUsageExtension class using an AsnEncodedData object and a value that identifies whether the extension is critical. |
![]() | X509EnhancedKeyUsageExtension(OidCollection, Boolean) | Initializes a new instance of the X509EnhancedKeyUsageExtension class using an OidCollection and a value that identifies whether the extension is critical. |
| Name | Description | |
|---|---|---|
![]() | Critical | Gets a Boolean value indicating whether the extension is critical. (Inherited from X509Extension.) |
![]() | EnhancedKeyUsages | Gets the collection of object identifiers (OIDs) that indicate the applications that use the key. |
![]() | Oid | Gets or sets the Oid value for an AsnEncodedData object. (Inherited from AsnEncodedData.) |
![]() | RawData | Gets or sets the Abstract Syntax Notation One (ASN.1)-encoded data represented in a byte array. (Inherited from AsnEncodedData.) |
| Name | Description | |
|---|---|---|
![]() | CopyFrom | Initializes a new instance of the X509EnhancedKeyUsageExtension class using an AsnEncodedData object. (Overrides X509Extension.CopyFrom(AsnEncodedData).) |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | Format | Returns a formatted version of the Abstract Syntax Notation One (ASN.1)-encoded data as a string. (Inherited from AsnEncodedData.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
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 X509EnhancedKeyUsageExtension class to display the information.
Imports System Imports System.Security.Cryptography Imports System.Security.Cryptography.X509Certificates Module CertSelect Sub Main() Try Dim store As New X509Store("MY", StoreLocation.CurrentUser) store.Open(OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly) Dim collection As X509Certificate2Collection = CType(store.Certificates, X509Certificate2Collection) Dim i As Integer For i = 0 To collection.Count Dim extension As X509Extension For Each extension In collection(i).Extensions Console.WriteLine(extension.Oid.FriendlyName + "(" + extension.Oid.Value + ")") If extension.Oid.FriendlyName = "Key Usage" Then Dim ext As X509KeyUsageExtension = CType(extension, X509KeyUsageExtension) Console.WriteLine(ext.KeyUsages) End If If extension.Oid.FriendlyName = "Basic Constraints" Then Dim ext As X509BasicConstraintsExtension = CType(extension, X509BasicConstraintsExtension) Console.WriteLine(ext.CertificateAuthority) Console.WriteLine(ext.HasPathLengthConstraint) Console.WriteLine(ext.PathLengthConstraint) End If If extension.Oid.FriendlyName = "Subject Key Identifier" Then Dim ext As X509SubjectKeyIdentifierExtension = CType(extension, X509SubjectKeyIdentifierExtension) Console.WriteLine(ext.SubjectKeyIdentifier) End If If extension.Oid.FriendlyName = "Enhanced Key Usage" Then Dim ext As X509EnhancedKeyUsageExtension = CType(extension, X509EnhancedKeyUsageExtension) Dim oids As OidCollection = ext.EnhancedKeyUsages Dim oid As Oid For Each oid In oids Console.WriteLine(oid.FriendlyName + "(" + oid.Value + ")") Next oid End If Next extension Next i store.Close() Catch Console.WriteLine("Information could not be written out for this certificate.") End Try End Sub End Module
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.


