System.Security.Cryptography.X509Certificates.X509Certificate.Export Method

Exports the current System.Security.Cryptography.X509Certificates.X509Certificate object to a byte array using the specified format and a password.

Syntax

public virtual byte[] Export (X509ContentType contentType, System.Security.SecureString password)

Parameters

contentType
One of the 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 System.Security.Cryptography.X509Certificates.X509Certificate object.

Remarks

The contentType parameter accepts only the following values of the System.Security.Cryptography.X509Certificates.X509ContentType enumeration: X509ContentType.Cert, X509ContentType.SerializedCert, and X509ContentType.Pkcs12. Passing any other value causes a System.Security.Cryptography.CryptographicException to be thrown.

Note:

Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the MSIL Disassembler (Ildasm.exe), a hex editor, or by simply opening the assembly in a text editor such as Notepad.exe.

Requirements

Namespace: System.Security.Cryptography.X509Certificates
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0