ApplyPAdESLongTermValidation

Digital signatures

Description

Promotes an already-signed PDF to PAdES-B-LT in one call, writing the result to a file.

Syntax

Delphi

Function TPDFlib.ApplyPAdESLongTermValidation(Const InputFile, Password, OutputFile, FieldName: WideString; Options: Integer): Integer;

Parameters

InputFileThe signed PDF.
PasswordThe password to open it, or an empty string.
OutputFileThe augmented PDF to write.
FieldNameA signature field to process, or an empty string to process every signature into one revision.
OptionsA PADES_LTV_* bit mask; 0 selects PADES_LTV_DEFAULT.

Options

PADES_LTV_WRITE_VRI (1)Write a VRI entry for each signature.
PADES_LTV_FETCH_OCSP (2)Ask each link's OCSP responder.
PADES_LTV_FETCH_CRL (4)Fall back to the CRL when OCSP returned nothing.
PADES_LTV_FOLLOW_AIA (8)Follow issuer addresses to complete the path.
PADES_LTV_SKIP_EXISTING (16)Do not re-add material whose bytes are already staged.
PADES_LTV_SKIP_ROOT_REVOCATION (32)Do not ask for a self-issued root's status.
PADES_LTV_DEFAULT (63)All of the above; selected when Options is 0.

Return values

1The promotion succeeded.
2The input file could not be read.
3The input PDF could not be parsed.
10The output could not be written.
11The document security store could not be added.
20No such signature field.
21No processed signature carried a readable certificate.

GetPAdESLTVError carries the reason for any value other than 1.

Remarks

The signer certificate path is built from the signature's own CMS, and the remaining issuers are followed through the caIssuers addresses the certificates name when PADES_LTV_FOLLOW_AIA is set. Revocation is gathered for each link - OCSP first, then a CRL - and, with the certificates, written into the document security store by a single incremental update.

Material identical to something already staged is written once and referenced by every signature that needs it, so a certificate authority shared across the path or across signatures does not appear twice. A VRI entry is written only when it has a certificate to point at, so an empty entry is never produced.

An unreachable responder does not fail the call: the promotion proceeds with whatever was gathered, and GetPAdESLTVCertificateCount, GetPAdESLTVCRLCount, GetPAdESLTVOCSPCount and GetPAdESLTVError report what was obtained and why anything was missed.

Example

PDF.SetTimeStampOptions(2, 1, 1, 15000, '');
if PDF.ApplyPAdESLongTermValidation('signed.pdf', '', 'signed-lt.pdf', '', 0)<> 1 then
  ShowMessage(PDF.GetPAdESLTVError);

See also

ApplyPAdESLongTermValidationToStream, GetSignatureCertificateChainLength, AddPAdESDSSOCSPFromCertificates