Show / Hide Table of Contents

# Class X509Certificate

This class represents an X509 public-key certificate, as specified in RFC 5280.

##### Inheritance

object
X509Certificate

##### Implements

IDisposable

##### Inherited Members

object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()

###### Namespace: pdftron.Crypto

###### Assembly: PDFNet.dll

##### Syntax

    public sealed class X509Certificate : IDisposable

### Constructors

#### X509Certificate(byte[])

Constructor from buffer. The input must be in DER, BER, or PEM encoding. The certificate must be in X.509 format.

##### Declaration

    public X509Certificate(byte[] in_cert_buf)

##### Parameters

Type | Name | Description
--- | --- | ---
byte[] | in_cert_buf | a buffer containing the certificate

#### X509Certificate(string)

Constructor from filepath. The input must be in DER, BER, or PEM encoding. The certificate must be in X.509 format.

##### Declaration

    public X509Certificate(string in_certificate_path)

##### Parameters

Type | Name | Description
--- | --- | ---
string | in_certificate_path | the path to the file containing the certificate

### Methods

#### Dispose()

##### Declaration

    public override sealed void Dispose()

#### Dispose(bool)

##### Declaration

    [HandleProcessCorruptedStateExceptions]
    protected void Dispose(bool A_0)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | A_0 |

#### ~X509Certificate()

##### Declaration

    protected ~X509Certificate()

#### GetData()

Retrieves the certificate as binary DER-encoded data. (DER is short for Distinguished Encoding Rules.)

##### Declaration

    public byte[] GetData()

##### Returns

Type | Description
--- | ---
byte[] | a container of bytes representing the certificate, encoded as binary DER

#### GetExtensions()

Retrieves all extensions (as first specified in V3 of X509, see RFC 5280) from the certificate.

##### Declaration

    public X509Extension[] GetExtensions()

##### Returns

Type | Description
--- | ---
X509Extension[] | a container of X509Extension objects

#### GetFingerprint()

Retrieves, in a string, a text representation of a cryptographically-secure digest of the certificate that can be used to identify it uniquely. Note: Default algorithm parameter is currently SHA-256, but may change in future without further warning, pursuant to security needs.

##### Declaration

    public string GetFingerprint()

##### Returns

Type | Description
--- | ---
string | a string representation of the fingerprint, in the form of double ASCII characters representing hex bytes, separated by colons

#### GetFingerprint(Type)

Retrieves, in a string, a text representation of a cryptographically-secure digest of the certificate that can be used to identify it uniquely.

##### Declaration

    public string GetFingerprint(DigestAlgorithm.Type in_digest_algorithm)

##### Parameters

Type | Name | Description
--- | --- | ---
DigestAlgorithm.Type | in_digest_algorithm | An enumeration representing the digest algorithm to use. Currently supported are SHA-1 (SHA-160), SHA-256, SHA-384, and SHA-512.

##### Returns

Type | Description
--- | ---
string | a string representation of the fingerprint, in the form of double ASCII characters representing hex bytes, separated by colons

##### Remarks

Default algorithm parameter is currently SHA-256, but may change in future without further warning, pursuant to security needs.

#### GetIssuerField()

Retrieves the names of the certificate issuer as a map of OIDs (i.e. one of the object identifiers from the X.500 attribute types) to string values. The issuer field identifies the entity that has signed and issued the certificate. The returned value will contain all of the AttributeTypeAndValue items from all of the RelativeDistinguishedNames in the Name of the issuer. See RFC 5280, section 4.1.2.4 and Appendix A.1 (page 116).

##### Declaration

    public X501DistinguishedName GetIssuerField()

##### Returns

Type | Description
--- | ---
X501DistinguishedName | an X501DistinguishedName object

#### GetNotAfterEpochTime()

Retrieves the notAfter time from the certificate's Validity entry in the form of an integral value representing an epoch time.

##### Declaration

    public long GetNotAfterEpochTime()

##### Returns

Type | Description
--- | ---
long | an integer containing an epoch time

#### GetNotBeforeEpochTime()

Retrieves the notBefore time from the certificate's Validity entry in the form of an integral value representing an epoch time.

##### Declaration

    public long GetNotBeforeEpochTime()

##### Returns

Type | Description
--- | ---
long | an integer containing an epoch time

#### GetRawX509VersionNumber()

Retrieves the version number representing which version of X509 the certificate corresponds to, from the certificate.

##### Declaration

    public uint GetRawX509VersionNumber()

##### Returns

Type | Description
--- | ---
uint | an integer containing the version number

##### Remarks

The X509 version number in the certificate, which we return unchanged here, is zero-indexed and therefore is one less in value than the actual version. e.g. X509v3 is represented by a returned version number of 2.

#### GetSerialNumber()

Retrieves the serialNumber entry from the certificate.

##### Declaration

    public byte[] GetSerialNumber()

##### Returns

Type | Description
--- | ---
byte[] | a big-integer-style container holding bytes representing the components of an integral serial number in big-endian order

#### GetSubjectField()

Retrieves the names of the certificate subject as a map of OIDs (i.e. one of the object identifiers from the X.500 attribute types) to string values. The subject field represents the identity of the entity associated with the certificate's public key. The returned value will contain all of the AttributeTypeAndValue items from all of the RelativeDistinguishedNames in the Name of the subject. See RFC 5280, section 4.1.2.6 and Appendix A.1 (page 116).

##### Declaration

    public X501DistinguishedName GetSubjectField()

##### Returns

Type | Description
--- | ---
X501DistinguishedName | an X501DistinguishedName object

#### ToString()

Returns a string representation of the certificate.

##### Declaration

    public override sealed string ToString()

##### Returns

Type | Description
--- | ---
string | a string representation of the certificate

##### Overrides

object.ToString()

##### Remarks

Output may change in future versions.

### Implements

IDisposable