ApplyPAdESLongTermValidationA

Digital signatures

Requires the Enterprise edition — in Delphi, C++Builder and Lazarus code create the library as TPDFlibEnterprise (unit PDFlibEnterprise); the Enterprise DLL and ActiveX builds provide it unchanged; other editions keep the method, which returns 0, an empty string or False and sets LastErrorCode to 900 (PDFLIB_ERROR_ENTERPRISE_REQUIRED)

Description

The trailing A denotes the ANSI (char) DLL entry point; the ActiveX/COM surface exposes only the Unicode form. Behaviour is identical to ApplyPAdESLongTermValidation and string arguments are interpreted using the current SetAnsiMode code page

Promotes an already-signed PDF to PAdES-B-LT in one call, writing the result to a file after at least one signature yields readable CMS material so failed calls preserve any existing destination file

Syntax

Delphi

Function DLApplyPAdESLongTermValidationA(InstanceID: Integer; InputFile: PAnsiChar; Password: PAnsiChar; OutputFile: PAnsiChar; FieldName: PAnsiChar; Options: Integer): Integer;

DLL

int DLApplyPAdESLongTermValidationA(int InstanceID, const char* InputFile, const char* Password, const char* OutputFile, const char* FieldName, int Options);

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