X509Certificate2.TryExportCertificatePem(Span<Char>, Int32) Method

Definition

Attempts to export the public X.509 certificate, encoded as PEM.

public:
 bool TryExportCertificatePem(Span<char> destination, [Runtime::InteropServices::Out] int % charsWritten);
public bool TryExportCertificatePem (Span<char> destination, out int charsWritten);
member this.TryExportCertificatePem : Span<char> * int -> bool
Public Function TryExportCertificatePem (destination As Span(Of Char), ByRef charsWritten As Integer) As Boolean

Parameters

destination
Span<Char>

The buffer to receive the PEM encoded certificate.

charsWritten
Int32

When this method returns, the total number of characters written to destination.

Returns

true if destination was large enough to receive the encoded PEM; otherwise, false.

Exceptions

The certificate is corrupt, in an invalid state, or could not be exported to PEM.

Remarks

A PEM-encoded X.509 certificate will begin with -----BEGIN CERTIFICATE----- and end with -----END CERTIFICATE-----, with the base64 encoded DER contents of the certificate between the PEM boundaries.

          The certificate is encoded according to the IETF RFC 7468 "strict" encoding rules.

Applies to