Skip to content

PdfTimestampClient class

View as Markdown

Namespace: PdfNetStack.Signing
Assembly: PdfNetStack.dll
Package: PdfNetStack

An RFC 3161 time stamp authority. The library builds the request and checks the reply; the application supplies the transport, usually an HTTP POST of the request with content type application/timestamp-query that returns the application/timestamp-reply body. The library itself never opens a connection.

public sealed class PdfTimestampClient

Inheritance

object ← PdfTimestampClient

var http = new HttpClient();
var tsa = new PdfTimestampClient(request =>
{
    using var content = new ByteArrayContent(request);
    content.Headers.ContentType = new MediaTypeHeaderValue("application/timestamp-query");
    using HttpResponseMessage reply = http.PostAsync("https://tsa.example/", content).GetAwaiter().GetResult();
    reply.EnsureSuccessStatusCode();
    return reply.Content.ReadAsByteArrayAsync().GetAwaiter().GetResult();
});

Creates a client that sends each DER encoded TimeStampReq through send and reads the DER TimeStampResp it returns.

public PdfTimestampClient(Func<byte[], byte[]> send)

send Func<byte[], byte[]>

The hash sent to the authority. Default SHA-256.

public PdfDigestAlgorithm Digest { get; init; }

PdfDigestAlgorithm

The policy to request, as an object identifier; null for the authority’s default.

public string? PolicyOid { get; init; }

string?

Bytes reserved in the PDF for a token. Default 12288, enough for a token that carries the authority’s certificate chain. Signing fails, after the request, when a token is larger.

public int ReservedSize { get; init; }

int

Timestamps data: sends its hash with a random nonce and returns the DER encoded token after checking the reply. The reply must grant the request, echo the hash and the nonce, and be signed by a certificate in the token that is marked for time stamping only (a critical extended key usage).

public byte[] GetToken(byte[] data)

data byte[]

byte[]

CryptographicException

The authority refused the request or its reply is invalid.