Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Security.​Cryptography.​X509Certificates.​X509Certificate

Assembly: System.Security.Cryptography

Inheritance: object → X509Certificate

Provides methods that help you use X.509 v.3 certificates.

Properties

public nint
Handle
Gets a handle to a Microsoft Cryptographic API certificate context described by an unmanaged <see langword="PCCERT_CONTEXT" /> structure.
public string
Issuer
Gets the name of the certificate authority that issued the X.509v3 certificate.
SerialNumberBytes
Gets the big-endian representation of the certificate's serial number.
public string
Subject
Gets the subject distinguished name from the certificate.

Methods

public void
Dispose​()
Releases all resources used by the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object.
protected void
Dispose​(bool disposing)
disposing <see langword="true" /> to release both managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.
Releases all of the unmanaged resources used by this <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> and optionally releases the managed resources.
public bool
Equals​(object obj)
obj An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object to compare to the current object.
Returns <see langword="true" /> if the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object is equal to the object specified by the <paramref name="obj" /> parameter; otherwise, <see langword="false" /> .
Compares two <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> objects for equality.
public bool
Equals​(X509Certificate other)
other An <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object to compare to the current object.
Returns <see langword="true" /> if the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object is equal to the object specified by the <paramref name="other" /> parameter; otherwise, <see langword="false" /> .
Compares two <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> objects for equality.
public byte[]
Export​(X509ContentType contentType)
contentType One of the <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> values that describes how to format the output data.
Returns An array of bytes that represents the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object.
Exports the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object to a byte array in a format described by one of the <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> values.
public byte[]
Export​(X509ContentType contentType, SecureString password)
contentType One of the <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> values that describes how to format the output data.
password The password required to access the X.509 certificate data.
Returns A byte array that represents the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object.
Exports the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object to a byte array using the specified format and a password.
public byte[]
Export​(X509ContentType contentType, string password)
contentType One of the <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> values that describes how to format the output data.
password The password required to access the X.509 certificate data.
Returns An array of bytes that represents the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object.
Exports the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object to a byte array in a format described by one of the <see cref="T:System.Security.Cryptography.X509Certificates.X509ContentType" /> values, and using the specified password.
public byte[]
ExportPkcs12​(PbeParameters exportParameters, string password)
exportParameters The algorithm parameters to use for the export.
password The password to use for the export.
Returns A byte array containing the encoded PKCS#12.
Exports the certificate and private key in PKCS#12 / PFX format.
public byte[]
ExportPkcs12​(Pkcs12ExportPbeParameters exportParameters, string password)
exportParameters The algorithm parameters to use for the export.
password The password to use for the export.
Returns A byte array containing the encoded PKCS#12.
Exports the certificate and private key in PKCS#12 / PFX format.
public byte[]
GetCertHash​()
Returns The hash value for the X.509 certificate.
Returns the hash value for the X.509v3 certificate as an array of bytes.
public byte[]
GetCertHash​(HashAlgorithmName hashAlgorithm)
hashAlgorithm The name of the cryptographic hash algorithm to use.
Returns A byte array that contains the hash value for the X.509 certificate.
Returns the hash value for the X.509v3 certificate that is computed by using the specified cryptographic hash algorithm.
public string
GetCertHashString​()
Returns The hexadecimal string representation of the X.509 certificate hash value.
Returns the SHA-1 hash value for the X.509v3 certificate as a hexadecimal string.
public string
GetCertHashString​(HashAlgorithmName hashAlgorithm)
hashAlgorithm The name of the cryptographic hash algorithm to use.
Returns The hexadecimal string representation of the X.509 certificate hash value.
Returns a hexadecimal string containing the hash value for the X.509v3 certificate computed using the specified cryptographic hash algorithm.
public string
GetEffectiveDateString​()
Returns The effective date for this X.509 certificate.
Returns the effective date of this X.509v3 certificate.
public string
GetExpirationDateString​()
Returns The expiration date for this X.509 certificate.
Returns the expiration date of this X.509v3 certificate.
public string
GetFormat​()
Returns The format of this X.509 certificate.
Returns the name of the format of this X.509v3 certificate.
public int
GetHashCode​()
Returns The hash code for the X.509 certificate as an integer.
Returns the hash code for the X.509v3 certificate as an integer.
public string
GetIssuerName​()
Returns The name of the certification authority that issued the X.509 certificate.
Returns the name of the certification authority that issued the X.509v3 certificate.
public string
GetKeyAlgorithm​()
Returns The key algorithm information for this X.509 certificate as a string.
Returns the key algorithm information for this X.509v3 certificate as a string.
public byte[]
GetKeyAlgorithmParameters​()
Returns The key algorithm parameters for the X.509 certificate as an array of bytes.
Returns the key algorithm parameters for the X.509v3 certificate as an array of bytes.
public string
GetKeyAlgorithmParametersString​()
Returns The key algorithm parameters for the X.509 certificate as a hexadecimal string.
Returns the key algorithm parameters for the X.509v3 certificate as a hexadecimal string.
public string
GetName​()
Returns The name of the principal to which the certificate was issued.
Returns the name of the principal to which the certificate was issued.
public byte[]
GetPublicKey​()
Returns The public key for the X.509 certificate as an array of bytes.
Returns the public key for the X.509v3 certificate as an array of bytes.
public string
GetPublicKeyString​()
Returns The public key for the X.509 certificate as a hexadecimal string.
Returns the public key for the X.509v3 certificate as a hexadecimal string.
public byte[]
GetRawCertData​()
Returns A byte array containing the X.509 certificate data.
Returns the raw data for the entire X.509v3 certificate as an array of bytes.
public string
GetRawCertDataString​()
Returns The X.509 certificate data as a hexadecimal string.
Returns the raw data for the entire X.509v3 certificate as a hexadecimal string.
public byte[]
GetSerialNumber​()
Returns The serial number of the X.509 certificate as an array of bytes in little-endian order.
Returns the serial number of the X.509v3 certificate as an array of bytes in little-endian order.
public string
GetSerialNumberString​()
Returns The serial number of the X.509 certificate as a big-endian hexadecimal string.
Returns the serial number of the X.509v3 certificate as a big-endian hexadecimal string.
public void
Import​(byte[] rawData)
rawData A byte array containing data from an X.509 certificate.
Populates the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object with data from a byte array.
public void
Import​(byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags)
rawData A byte array that contains data from an X.509 certificate.
password The password required to access the X.509 certificate data.
keyStorageFlags A bitwise combination of the enumeration values that control where and how to import the certificate.
Populates an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object using data from a byte array, a password, and a key storage flag.
public void
Import​(byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
rawData A byte array containing data from an X.509 certificate.
password The password required to access the X.509 certificate data.
keyStorageFlags A bitwise combination of the enumeration values that control where and how to import the certificate.
Populates the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object using data from a byte array, a password, and flags for determining how the private key is imported.
public void
Import​(string fileName)
fileName The name of a certificate file represented as a string.
Populates the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object with information from a certificate file.
public void
Import​(string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags)
fileName The name of a certificate file.
password The password required to access the X.509 certificate data.
keyStorageFlags A bitwise combination of the enumeration values that control where and how to import the certificate.
Populates an <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object with information from a certificate file, a password, and a key storage flag.
public void
Import​(string fileName, string password, X509KeyStorageFlags keyStorageFlags)
fileName The name of a certificate file represented as a string.
password The password required to access the X.509 certificate data.
keyStorageFlags A bitwise combination of the enumeration values that control where and how to import the certificate.
Populates the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object with information from a certificate file, a password, and a <see cref="T:System.Security.Cryptography.X509Certificates.X509KeyStorageFlags" /> value.
public void
Reset​()
Resets the state of the <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate2" /> object.
public string
ToString​()
Returns A string representation of the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object.
Returns a string representation of the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object.
public string
ToString​(bool fVerbose)
fVerbose <see langword="true" /> to produce the verbose form of the string representation; otherwise, <see langword="false" /> .
Returns A string representation of the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object.
Returns a string representation of the current <see cref="T:System.Security.Cryptography.X509Certificates.X509Certificate" /> object, with extra information, if specified.
public bool
TryGetCertHash​(HashAlgorithmName hashAlgorithm, Span`1 destination, Int32& bytesWritten)
protected void
Finalize​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object