PLExtractCMSSignerCertificate

Signature utilities

Description

Returns the DER certificate that produced one signer of a CMS SignedData blob, matched out of the embedded certificate set. Both SignerIdentifier alternatives are handled: issuerAndSerialNumber, and the [0] subjectKeyIdentifier form that a signer using a key identifier emits.

For a key-identifier signer the certificate whose subjectKeyID equals the signer's key identifier wins; for an issuer-and-serial signer both halves must match, because a serial number is only unique within one issuer. When several certificates match the first one in encoding order is returned.

The result is empty when the index is out of range, the signer cannot be read, the blob carries no certificates or no certificate matches. The walk reads structure only; it uses the read-only PDFlibCMSRead unit available in every edition.

Syntax

Delphi

Function PLExtractCMSSignerCertificate(Const CMSBytes: AnsiString;
  SignerIndex: Integer): AnsiString;

Parameters

CMSBytesOne complete binary DER ContentInfo containing SignedData
SignerIndexZero-based index of the SignerInfo entry inside the signerInfos set; use PLGetCMSSignerCount to learn the valid range

Return values

AnsiStringThe matching certificate's DER bytes
''The signer or its certificate is absent, or the index is negative or beyond the last signer

Remarks

This Pascal unit function has no separate DLL or ActiveX forwarding entry point.

See also

GetSignatureSignerCertificateDER, GetSignatureEmbeddedCertificateDER, PLCheckCMSSignedDataStructure, PLCheckSignatureByteRange