# PdfTimestampClient class

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

Namespace: [PdfNetStack.Signing](https://www.jadev-corp.com/api/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.

```csharp
public sealed class PdfTimestampClient
```

**Inheritance**

[object](https://learn.microsoft.com/dotnet/api/system.object) ← 
[PdfTimestampClient](https://www.jadev-corp.com/api/pdfnetstack-signing/pdftimestampclient/)

## Examples

<pre><code class="lang-csharp">var http = new HttpClient();
var tsa = new PdfTimestampClient(request =&gt;
{
    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();
});</code></pre>

## Constructors

### <a id="PdfNetStack_Signing_PdfTimestampClient__ctor_System_Func_System_Byte___System_Byte____"></a> PdfTimestampClient\(Func&lt;byte\[\], byte\[\]\>\)

Creates a client that sends each DER encoded TimeStampReq through <code class="paramref">send</code> and reads the DER TimeStampResp it returns.

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

#### Parameters

`send` [Func](https://learn.microsoft.com/dotnet/api/system.func\-2)<[byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\], [byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]\>

## Properties

### <a id="PdfNetStack_Signing_PdfTimestampClient_Digest"></a> Digest

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

```csharp
public PdfDigestAlgorithm Digest { get; init; }
```

#### Property Value

 [PdfDigestAlgorithm](https://www.jadev-corp.com/api/pdfnetstack-signing/pdfdigestalgorithm/)

### <a id="PdfNetStack_Signing_PdfTimestampClient_PolicyOid"></a> PolicyOid

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

```csharp
public string? PolicyOid { get; init; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)?

### <a id="PdfNetStack_Signing_PdfTimestampClient_ReservedSize"></a> ReservedSize

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.

```csharp
public int ReservedSize { get; init; }
```

#### Property Value

 [int](https://learn.microsoft.com/dotnet/api/system.int32)

## Methods

### <a id="PdfNetStack_Signing_PdfTimestampClient_GetToken_System_Byte___"></a> GetToken\(byte\[\]\)

Timestamps <code class="paramref">data</code>: 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).

```csharp
public byte[] GetToken(byte[] data)
```

#### Parameters

`data` [byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]

#### Returns

 [byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]

#### Exceptions

 [CryptographicException](https://learn.microsoft.com/dotnet/api/system.security.cryptography.cryptographicexception)

The authority refused the request or its reply is invalid.

## Used in

- [Digitally sign PDF files in C# and .NET](https://www.jadev-corp.com/guides/signatures/)

Source: https://www.jadev-corp.com/pdfnetstack/api/pdfnetstack-signing/pdftimestampclient/
