Table of Contents

Class X509Certificate2

Namespace
System.Security.Cryptography.X509Certificates
Assembly
System.Net.dll

Represents an X.509 certificate.

public class X509Certificate2 : X509Certificate
Inheritance
X509Certificate2
Inherited Members
Extension Methods

Constructors

X509Certificate2()

Initializes a new instance of the X509Certificate2 class.

public X509Certificate2()

X509Certificate2(byte[])

Initializes a new instance of the X509Certificate2 class using information from a byte array.

public X509Certificate2(byte[] rawData)

Parameters

rawData byte[]

A byte array containing data from an X.509 certificate.

X509Certificate2(byte[], byte[], string)

Initializes a new instance of the X509Certificate2 class using a string with the content of an X.509 public certificate, the private key and a password used to access the certificate.

public X509Certificate2(byte[] rawData, byte[] key, string password)

Parameters

rawData byte[]

A byte array containing data from an X.509 certificate.

key byte[]

A byte array containing a PEM private key.

password string

The password required to decrypt the private key. null if the rawData or key are not encrypted.

Remarks

This methods is exclusive of nanoFramework. There is no equivalent in .NET framework.

X509Certificate2(byte[], string, string)

Initializes a new instance of the X509Certificate2 class using a string with the content of an X.509 public certificate, the private key and a password used to access the certificate.

public X509Certificate2(byte[] rawData, string key, string password)

Parameters

rawData byte[]

A byte array containing data from an X.509 certificate.

key string

A string containing a private key in PEM or DER format.

password string

The password required to decrypt the private key. Set to null if the rawData or key are not encrypted and do not require a password.

Remarks

This methods is exclusive of .NET nanoFramework. There is no equivalent in .NET framework.

X509Certificate2(string)

Initializes a new instance of the X509Certificate2 class using a string with the content of an X.509 certificate.

public X509Certificate2(string certificate)

Parameters

certificate string

A string containing a X.509 certificate.

Remarks

This methods is exclusive of .NET nanoFramework. The equivalent .NET constructor accepts a file name as the parameter.

X509Certificate2(string, string, string)

Initializes a new instance of the X509Certificate2 class using a string with the content of an X.509 public certificate, the private key and a password used to access the private key.

public X509Certificate2(string rawData, string key, string password)

Parameters

rawData string

A string containing a X.509 certificate.

key string

A string containing a private key in PEM or DER format.

password string

The password required to decrypt the private key. Set to null if the rawData or key are not encrypted and do not require a password.

Remarks

This methods is exclusive of .NET nanoFramework. There is no equivalent in .NET framework.

Properties

HasPrivateKey

Gets a value that indicates whether an X509Certificate2 object contains a private key.

public bool HasPrivateKey { get; }

Property Value

bool

true if the X509Certificate2 object contains a private key; otherwise, false.

NotAfter

Gets the date (in UTC time) after which a certificate is no longer valid.

public DateTime NotAfter { get; }

Property Value

DateTime

A DateTime object that represents the expiration date for the certificate.

NotBefore

Gets the date (in UTC time) on which a certificate becomes valid.

public DateTime NotBefore { get; }

Property Value

DateTime

A DateTime object that represents the effective date of the certificate.

PrivateKey

Gets the private key, null if there isn't a private key.

public byte[] PrivateKey { get; }

Property Value

byte[]

Remarks

This will give you access directly to the raw decoded byte array of the private key

PublicKey

Gets the public key.

public byte[] PublicKey { get; }

Property Value

byte[]

Remarks

This will give you access directly to the raw decoded byte array of the public key.

RawData

Gets the raw data of a certificate.

public byte[] RawData { get; }

Property Value

byte[]

The raw data of the certificate as a byte array.