---
title: "Verify PDF timestamp authority trust in C#"
url: https://recursiveai.org/onepdf/cookbook/verify-pdf-timestamp-authority-trust/
description: "Use TrustAnchors in C# to verify the signer and RFC 3161 timestamp authority on a PDF, and read each certificate chain result separately."
version: "1.26.1"
---

# Verify PDF timestamp authority trust in C#

**OnePDF** is a free, open-source PDF library for .NET from Recursive AI. MIT or Apache-2.0, no native dependencies.

[NuGet](https://www.nuget.org/packages/RecursiveAI.OnePdf) · [GitHub](https://github.com/recursive-ai-oss/onepdf-csharp) · [Docs](https://recursiveai.org/onepdf/docs/) · [Download example (.zip)](https://recursiveai.org/onepdf/cookbook/verify-pdf-timestamp-authority-trust/verify-pdf-timestamp-authority-trust.zip)

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.

```shell
dotnet add package RecursiveAI.OnePdf
```

Requires [.NET 10](https://dotnet.microsoft.com/download/dotnet/10.0) (net10.0); .NET 9 and earlier aren’t supported.

```csharp
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](https://recursiveai.org/onepdf/cookbook/verify-pdf-timestamp-authority-trust/verify-pdf-timestamp-authority-trust.zip) and `dotnet run`.

```text
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](https://recursiveai.org/onepdf/docs/signatures/) notes: “Without anchors (and without `UseSystemTrustStore`) no chain is trusted.”

## Variations

**Show whether revocation was checked.** Add this to the loop:

```csharp
Console.WriteLine(
    $"Revocation: {result.Revocation}");
```

```text
Revocation: NotChecked
```

## Related recipes

- [Sign and verify a PDF in C#](https://recursiveai.org/onepdf/cookbook/sign-and-verify/)
- [External PDF signing](https://recursiveai.org/onepdf/cookbook/sign-pdf-external-signature/)

## 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.
