A timestamp authority signs a record of when the signature existed, and OnePDF checks its certificate chain separately from the signer’s. Use signed.pdf, signer-root.pem, and tsa-root.pem from the zip.
dotnet add package RecursiveAI.OnePdfRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OnePdf; using System.Security.Cryptography .X509Certificates; var signerPem = File.ReadAllText( "signer-root.pem"); using var signer = X509Certificate2.CreateFromPem(signerPem); var tsaPem = File.ReadAllText("tsa-root.pem"); using var tsa = X509Certificate2.CreateFromPem(tsaPem); using var doc = PdfDocument.Open("signed.pdf"); var options = new PdfSignatureVerifyOptions { TrustAnchors = [signer, tsa] }; var report = doc.VerifySignatures(options); foreach (var result in report.Signatures) { var signerChain = result.Chain; Console.WriteLine( $"Signer: {signerChain}"); var chain = result.Timestamp?.Chain; Console.WriteLine($"Timestamp: {chain}"); var valid = result.IsValid; Console.WriteLine( $"Signature valid: {valid}"); }
Paste the code above into Program.cs of a new dotnet new console project and dotnet run, or unzip the example and dotnet run.
Signer: Trusted Timestamp: Trusted Signature valid: True
The PEM files hold public CERTIFICATE blocks, not private keys; the signed PDF contains the notice “Public notice” on page 1. These roots are for the offline example only; use roots you trust from a source independent of the PDF. An absent timestamp has no Timestamp result; an untrusted timestamp makes IsValid false even if the signer’s chain is trusted. The signature guide notes: “Without anchors (and without UseSystemTrustStore) no chain is trusted.”
Variations
Show whether revocation was checked. Add this to the loop:
Console.WriteLine( $"Revocation: {result.Revocation}");
Revocation: NotCheckedRelated recipes
The short answer
Put the approved signer and timestamp authority roots in PdfSignatureVerifyOptions.TrustAnchors, then call VerifySignatures. Read result.Chain for the signer and result.Timestamp?.Chain for the timestamp authority. Check result.IsValid for the combined signature result; a trusted chain on its own doesn’t show that the signed bytes match.
How do you verify a timestamp on a digital signature?
OnePDF checks whether the token matches the data it claims to timestamp, verifies the authority’s signature on that token, and builds the authority’s certificate chain at the time in the token. Check Timestamp.IsValid when you need the result for the token itself, not just the chain. For an application that requires timestamps, treat a missing token separately: a digital signature can pass verification without carrying one.
What should you do if a PDF signature isn’t validating?
Read the signer chain and timestamp chain separately before changing your trust configuration. Incomplete can mean the verifier needs another certificate to build a chain; provide approved intermediates through ExtraCertificates. UntrustedRoot means the chain doesn’t end at a trusted root. Don’t fix that by trusting a root simply because it arrived with the document. If both chains are trusted but the signature is invalid, inspect Integrity, SignatureCheck, and Changes to distinguish a digest mismatch, a signature check failure, or a disallowed later edit.
Does a timestamp still validate after the authority certificate expires?
OnePDF checks the authority’s chain at the time in the token, not the day you open the PDF. A certificate that expired later is therefore different from one that was already expired when the authority issued the token. The verifier does not fetch issuer certificates or revocation data over the network. If your policy requires revocation checks, supply a RevocationCheck backed by revocation information you already hold; without it, NotChecked isn’t evidence that a certificate was never revoked.