X509Certificate Class
Provides methods that help you use X.509 v.3 certificates.
System.Security.Cryptography.X509Certificates::X509Certificate
System.Security.Cryptography.X509Certificates::X509Certificate2
Namespace: System.Security.Cryptography.X509Certificates
Assembly: mscorlib (in mscorlib.dll)
The X509Certificate type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | X509Certificate() | Initializes a new instance of the X509Certificate class. |
![]() | X509Certificate(array<Byte>) | Initializes a new instance of the X509Certificate class defined from a sequence of bytes representing an X.509v3 certificate. |
![]() | X509Certificate(IntPtr) | Initializes a new instance of the X509Certificate class using a handle to an unmanaged PCCERT_CONTEXT structure. |
![]() | X509Certificate(String) | Initializes a new instance of the X509Certificate class using the name of a PKCS7 signed file. |
![]() | X509Certificate(X509Certificate) | Initializes a new instance of the X509Certificate class using another X509Certificate class. |
![]() | X509Certificate(array<Byte>, SecureString) | Initializes a new instance of the X509Certificate class using a byte array and a password. |
![]() | X509Certificate(array<Byte>, String) | Initializes a new instance of the X509Certificate class using a byte array and a password. |
![]() | X509Certificate(SerializationInfo, StreamingContext) | Initializes a new instance of the X509Certificate class using a SerializationInfo object and a StreamingContext structure. |
![]() | X509Certificate(String, SecureString) | Initializes a new instance of the X509Certificate class using a certificate file name and a password. |
![]() | X509Certificate(String, String) | Initializes a new instance of the X509Certificate class using the name of a PKCS7 signed file and a password to access the certificate. |
![]() | X509Certificate(array<Byte>, SecureString, X509KeyStorageFlags) | Initializes a new instance of the X509Certificate class using a byte array, a password, and a key storage flag. |
![]() | X509Certificate(array<Byte>, String, X509KeyStorageFlags) | Initializes a new instance of the X509Certificate class using a byte array, a password, and a key storage flag. |
![]() | X509Certificate(String, SecureString, X509KeyStorageFlags) | Initializes a new instance of the X509Certificate class using a certificate file name, a password, and a key storage flag. |
![]() | X509Certificate(String, String, X509KeyStorageFlags) | Initializes a new instance of the X509Certificate class using the name of a PKCS7 signed file, a password to access the certificate, and a key storage flag. |
| Name | Description | |
|---|---|---|
![]() ![]() | CreateFromCertFile | Creates an X.509v3 certificate from the specified PKCS7 signed file. |
![]() ![]() | CreateFromSignedFile | Creates an X.509v3 certificate from the specified signed file. |
![]() | Equals(Object) | Compares two X509Certificate objects for equality. (Overrides Object::Equals(Object).) |
![]() | Equals(X509Certificate) | Compares two X509Certificate objects for equality. |
![]() | Export(X509ContentType) | Exports the current X509Certificate object to a byte array in a format described by one of the X509ContentType values. |
![]() | Export(X509ContentType, SecureString) | Exports the current X509Certificate object to a byte array using the specified format and a password. |
![]() | Export(X509ContentType, String) | Exports the current X509Certificate object to a byte array in a format described by one of the X509ContentType values, and using the specified password. |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() ![]() | FormatDate | Converts the specified date and time to a string. |
![]() | GetCertHash | Returns the hash value for the X.509v3 certificate as an array of bytes. |
![]() | GetCertHashString | Returns the SHA1 hash value for the X.509v3 certificate as a hexadecimal string. |
![]() | GetEffectiveDateString | Returns the effective date of this X.509v3 certificate. |
![]() | GetExpirationDateString | Returns the expiration date of this X.509v3 certificate. |
![]() | GetFormat | Returns the name of the format of this X.509v3 certificate. |
![]() | GetHashCode | Returns the hash code for the X.509v3 certificate as an integer. (Overrides Object::GetHashCode().) |
![]() | GetIssuerName | Obsolete. Returns the name of the certification authority that issued the X.509v3 certificate. |
![]() | GetKeyAlgorithm | Returns the key algorithm information for this X.509v3 certificate. |
![]() | GetKeyAlgorithmParameters | Returns the key algorithm parameters for the X.509v3 certificate. |
![]() | GetKeyAlgorithmParametersString | Returns the key algorithm parameters for the X.509v3 certificate. |
![]() | GetName | Obsolete. Returns the name of the principal to which the certificate was issued. |
![]() | GetPublicKey | Returns the public key for the X.509v3 certificate. |
![]() | GetPublicKeyString | Returns the public key for the X.509v3 certificate. |
![]() | GetRawCertData | Returns the raw data for the entire X.509v3 certificate. |
![]() | GetRawCertDataString | Returns the raw data for the entire X.509v3 certificate. |
![]() | GetSerialNumber | Returns the serial number of the X.509v3 certificate. |
![]() | GetSerialNumberString | Returns the serial number of the X.509v3 certificate. |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | Import(array<Byte>) | Populates the X509Certificate object with data from a byte array. |
![]() | Import(String) | Populates the X509Certificate object with information from a certificate file. |
![]() | Import(array<Byte>, SecureString, X509KeyStorageFlags) | Populates an X509Certificate object using data from a byte array, a password, and a key storage flag. |
![]() | Import(array<Byte>, String, X509KeyStorageFlags) | Populates the X509Certificate object using data from a byte array, a password, and flags for determining how the private key is imported. |
![]() | Import(String, SecureString, X509KeyStorageFlags) | Populates an X509Certificate object with information from a certificate file, a password, and a key storage flag. |
![]() | Import(String, String, X509KeyStorageFlags) | Populates the X509Certificate object with information from a certificate file, a password, and a X509KeyStorageFlags value. |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | Reset | Resets the state of the X509Certificate2 object. |
![]() | ToString() | Returns a string representation of the current X509Certificate object. (Overrides Object::ToString().) |
![]() | ToString(Boolean) | Returns a string representation of the current X509Certificate object, with extra information, if specified. |
| Name | Description | |
|---|---|---|
![]() ![]() | IDeserializationCallback::OnDeserialization | Implements the ISerializable interface and is called back by the deserialization event when deserialization is complete. |
![]() ![]() | ISerializable::GetObjectData | Gets serialization information with all the data needed to recreate an instance of the current X509Certificate object. |
ASN.1 DER is the only certificate format supported by this class.
For most scenarios, you should use the X509Certificate2 class instead.
The following example loads an X.509 certificate from a file, calls the ToString method, and displays the results to the console.
using namespace System; using namespace System::Security::Cryptography::X509Certificates; int main() { // The path to the certificate. String^ Certificate = L"Certificate.cer"; // Load the certificate into an X509Certificate object. X509Certificate^ cert = gcnew X509Certificate( Certificate ); // Get the value. String^ resultsTrue = cert->ToString( true ); // Display the value to the console. Console::WriteLine( resultsTrue ); // Get the value. String^ resultsFalse = cert->ToString( false ); // Display the value to the console. Console::WriteLine( resultsFalse ); }
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.gif?cs-save-lang=1&cs-lang=cpp)
.gif?cs-save-lang=1&cs-lang=cpp)
.gif?cs-save-lang=1&cs-lang=cpp)
.gif?cs-save-lang=1&cs-lang=cpp)
.gif?cs-save-lang=1&cs-lang=cpp)
.gif?cs-save-lang=1&cs-lang=cpp)