ApplyPAdESLongTermValidation
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
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 TPDFlib.ApplyPAdESLongTermValidation(Const InputFile, Password, OutputFile, FieldName: WideString; Options: Integer): Integer; Virtual;ActiveX
Function PDFlib::ApplyPAdESLongTermValidation(InputFile As String, Password As String, OutputFile As String, FieldName As String, Options As Long) As LongDLL
int DLApplyPAdESLongTermValidation(int InstanceID, const wchar_t* InputFile, const wchar_t* Password, const wchar_t* OutputFile, const wchar_t* FieldName, int Options);
int DLApplyPAdESLongTermValidationA(int InstanceID, const char* InputFile, const char* Password, const char* OutputFile, const char* FieldName, int Options);Parameters
| InputFile | The signed PDF |
|---|---|
| Password | The password to open it, or an empty string |
| OutputFile | The augmented PDF to write |
| FieldName | A signature field to process, or an empty string to process every signature into one revision |
| Options | A 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
| 1 | The promotion succeeded |
|---|---|
| 2 | The input file could not be read |
| 3 | The input PDF could not be parsed |
| 10 | The output could not be written |
| 11 | The document security store could not be added |
| 20 | No such signature field |
| 21 | No 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