SetPAdESSignatureTimeStampToken
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)
Security and Signatures
Description
Validates a DER-encoded RFC 3161 TimeStampToken and injects it as an id-aa-signatureTimeStampToken unsigned attribute on the selected CMS SignerInfo
The method verifies the token signature, requires the sole critical extended key usage to be timeStamping, checks an encoded TSA name when present, and compares the token message imprint with the configured digest of the signer signatureValue
Existing signature timestamp attributes on the selected signer are replaced, unrelated unsigned attributes are preserved, and the rebuilt attribute set is DER sorted
Syntax
Delphi
Function TPDFlib.SetPAdESSignatureTimeStampToken(STSProcessID: Integer;
Const TimeStampTokenDER: AnsiString; SignerIndex: Integer= 0): Integer; Virtual;ActiveX
Function PDFlib::SetPAdESSignatureTimeStampToken(STSProcessID As Long, TimeStampTokenDER As Variant, SignerIndex As Long) As LongDLL
int DLSetPAdESSignatureTimeStampToken(int InstanceID, int STSProcessID, const char* TimeStampTokenDER, int TimeStampTokenDERLength, int SignerIndex);
Parameters
| STSProcessID | Value returned by one of the NewPAdESSignatureTimeStampProcessFrom* functions |
|---|---|
| TimeStampTokenDER | Complete DER-encoded RFC 3161 TimeStampToken returned by the TSA |
| SignerIndex | Zero-based CMS signer index, defaulting to the first signer |
Return values
| 0 | The process identifier is invalid |
|---|---|
| 1 | The token was validated and injected |
| 11 | The token, CMS, selected signer, TSA constraints, or message imprint is invalid |
| 17 | A later signature or document time stamp covers the target signature value; attaching the token would invalidate it (see GetPAdESSignatureTimeStampProcessResult) |
| Other | The source PDF or selected signature could not be prepared, as reported by GetPAdESSignatureTimeStampProcessResult |
Workflow
- Reserve enough signature contents space with
SetSignProcessReserveContentsBytesbefore creating the original signature - Create a timestamp process and select the signature field and digest algorithm
- Call
GetPAdESSignatureValueHashHexand send that message imprint to the TSA - Pass the returned TimeStampToken to this method
- Finish with an
EndPAdESSignatureTimeStampProcessTo*method
The library validates and rewrites CMS but does not perform the TSA HTTP request
See also
GetPAdESSignatureValueHashHex, SetPAdESSignatureTimeStampDigestAlgorithm, SetSignProcessReserveContentsBytes, TPDFlibSignatureVerifier