Table of Contents

Codeunit X509Certificate2

ID 1286
Namespace: System.Security.Encryption

Provides helper functions to work with the X509Certificate2 class.

Properties

Name Value
Access Public
InherentEntitlements X
InherentPermissions X

Methods

VerifyCertificate

Verifes that a certificate is initialized and can be exported.

procedure VerifyCertificate(var CertBase64Value: Text, Password: SecretText, X509ContentType: Enum "X509 Content Type"): Boolean

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

X509ContentType Enum System.Security.Encryption."X509 Content Type"

Specifies the format of an X.509 certificate

Returns

Type Description
Boolean

True if certificate is verified

GetCertificateFriendlyName

Specifies the friendly name of the certificate based on it's Base64 value.

procedure GetCertificateFriendlyName(CertBase64Value: Text, Password: SecretText, var FriendlyName: Text)

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

FriendlyName Text

Represents certificate Friendly Name

GetCertificateSubject

Specifies the subject of the certificate based on it's Base64 value.

procedure GetCertificateSubject(CertBase64Value: Text, Password: SecretText, var Subject: Text)

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

Subject Text

Certificate subject distinguished name

GetCertificateThumbprint

Specifies the thumbprint of the certificate based on it's Base64 value.

procedure GetCertificateThumbprint(CertBase64Value: Text, Password: SecretText, var Thumbprint: Text)

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

Thumbprint Text

Certificate Thumbprint

GetCertificateIssuer

Specifies the issuer of the certificate based on it's Base64 value.

procedure GetCertificateIssuer(CertBase64Value: Text, Password: SecretText, var Issuer: Text)

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

Issuer Text

Certificate Issuer

GetCertificateExpiration

Specifies the expiration date of the certificate based on it's Base64 value.

procedure GetCertificateExpiration(CertBase64Value: Text, Password: SecretText, var Expiration: DateTime)

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

Expiration DateTime

Certificate Expiration Date

GetCertificateNotBefore

Specifies the NotBefore date of the certificate based on it's Base64 value.

procedure GetCertificateNotBefore(CertBase64Value: Text, Password: SecretText, var NotBefore: DateTime)

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

NotBefore DateTime

Certificate NotBefore Date

HasPrivateKey

Checks whether the certificate has a private key based on it's Base64 value.

procedure HasPrivateKey(CertBase64Value: Text, Password: SecretText): Boolean

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

Returns

Type Description
Boolean

True if the certificate has private key

GetCertificatePropertiesAsJson

Specifies the certificate details in Json object

procedure GetCertificatePropertiesAsJson(CertBase64Value: Text, Password: SecretText, var CertPropertyJson: Text)

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

CertPropertyJson Text

Certificate details in json

GetCertificatePublicKey

Gets Certificate public key

procedure GetCertificatePublicKey(CertBase64Value: Text, Password: SecretText): Text

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

Returns

Type Description
Text

An XML string containing the public key of the certificate

GetCertificatePrivateKey

Gets Certificate private key

procedure GetCertificatePrivateKey(CertBase64Value: Text, Password: SecretText): SecretText

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

Returns

Type Description
SecretText

GetCertificateSerialNumber

Gets Certificate serial number

procedure GetCertificateSerialNumber(CertBase64Value: Text, Password: SecretText, var SerialNumber: Text)

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

SerialNumber Text

Certificate serial number

GetCertificateSerialNumberAsASCII

Gets Certificate serial number as ASCII

procedure GetCertificateSerialNumberAsASCII(CertBase64Value: Text, Password: SecretText, var SerialNumberASCII: Text)

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

SerialNumberASCII Text

Certificate serial number as ascii

GetCertificatePublicKeyAsBase64String

Gets certificate public key as Base64 string

procedure GetCertificatePublicKeyAsBase64String(CertBase64Value: Text, Password: SecretText): Text

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

Returns

Type Description
Text

The certificate public key

GetRawCertDataAsBase64String

Returns the raw data for the certificate as a Base64 string.

procedure GetRawCertDataAsBase64String(CertBase64Value: Text, Password: SecretText): Text

Parameters

Name Type Description
CertBase64Value Text

Represents the certificate value encoded using the Base64 algorithm

Password SecretText

Certificate Password

Returns

Type Description
Text

A Base64 string containing the X.509 certificate data

CreateFromPemAndExportAsBase64

Creates a new instance of X509Certificate2 from the specified Base64 encoded certificate value. The certificate is exported as Base64 encoded string.

procedure CreateFromPemAndExportAsBase64(CertificateBase64: Text, PrivateKeyXmlString: SecretText, Password: SecretText): Text

Parameters

Name Type Description
CertificateBase64 Text

The Base64 encoded certificate in PEM format.

PrivateKeyXmlString SecretText

The private key in XML format.

Password SecretText

The password to protect the private key.

Returns

Type Description
Text

The Base64 encoded certificate including the private key.

See also