Asynchronous Signature Evidence Acquisition

THPDFSignatureEvidenceTask acquires timestamp tokens, OCSP responses, and CRLs on background workers without coupling HotPDF to a particular HTTP, proxy, or authentication stack

Requests and transport

Each THPDFSignatureEvidenceRequest identifies the evidence kind, URI, content type, request body, correlation identifier, and maximum accepted response size

The transport callback receives one request, a one-based attempt number, and a cancellation token, then returns a response, optional retry delay, diagnostic text, and one of setsSucceeded, setsRetry, setsPermanentFailure, or setsCancelled

The callback may use THTTPClient, Indy, WinHTTP, an enterprise proxy client, an application-specific offline service, or the optional in-tree HPDFNetworkTransport unit

HPDFNetworkTransport loads WinHTTP dynamically on Windows and libcurl dynamically on UNIX systems, parses bracketed IPv6 literal URIs per RFC 3986, enforces bounded 301/302/303/307/308 redirects and response-size caps, honours Retry-After headers on 429/503/5xx responses, and exposes HPDFMakeSignatureEvidenceTransport, HPDFMakeCMSTimestampCallback and HPDFNetworkHeadlessTimestampTransport across Delphi and Free Pascal 3.2.2+

Revocation URL and request discovery

HPDFExtractCertificateRevocationURLs harvests the OCSP responder and CRL distribution URLs out of one certificate's AIA and CRLDistributionPoints extensions into THPDFURLArray outputs, returning False where the certificate DER cannot be parsed and empty arrays where the certificate advertises no revocation endpoints

HPDFCollectCMSRevocationRequests builds one GET pkix-crl request per CRL distribution URL and one POST ocsp-request per OCSP responder URL for every certificate in the CMS, using a minimal RFC 6960 OCSPRequest with a SHA-256 CertID, and collapses duplicate URIs into a single request

Both routines only prepare or describe work: the caller's transport still does every fetch, so the same offline or authenticated path that serves timestamp evidence serves revocation evidence too

Retry and concurrency

THPDFSignatureEvidenceRetryPolicy.Default performs up to three attempts, starts at 250 milliseconds, doubles delays to a 10-second ceiling, and caps server-requested retry delays at 30 seconds

Worker count is bounded per task, request order remains stable in the result array, retry waits poll cancellation every 50 milliseconds, and transport exceptions enter the retry path with their diagnostic message retained

Results and cancellation

SnapshotResults returns a thread-safe deep copy whilst acquisition continues, WaitForResults waits for completion, and Cancel marks queued and active work as cancelled through a shared token

Results distinguish success, permanent failure, exhausted retries, cancellation, and oversized responses, and include the attempt count, response bytes, and last diagnostic text

Successful timestamp bytes can feed THPDFCMSSignOptions.GetSignatureTimeStamp, whilst OCSP and CRL bytes can populate signing revocation attributes, DSS entries, or THPDFCertificateValidationOptions

What a timestamp callback must return

The bytes a callback returns are embedded verbatim as the unsigned signature-time-stamp attribute and are re-verified later as a CMS SignedData token of their own, so the callback has to hand over a response the TSA actually signed

HotPDF deliberately offers no helper that builds such a token: HPDFCMSValidateTimeStampToken checks the ContentInfo envelope, the id-ct-TSTInfo content type, the encapsulated TSTInfo and an exact message-imprint match, but neither the TSA signature nor a certificate chain, so an in-library token builder would produce a byte string that passes that validator with no authority behind it

Verification of a loaded signature goes further than that validator and does check the token's own signature, so a structurally complete but unsigned token cannot reach a valid verdict; THPDFCMSVerifyOptions.SkipSignatureTimestampVerification is the only supported way to leave the token unverified, and it reports the token status as svNotVerified whilst the primary signature is still fully checked