Table of Contents

Class TsaPool

Namespace
SimpleSign.Core.Crypto
Assembly
SimpleSign.Core.dll

A pool of TSA (Time Stamp Authority) servers with automatic failover. When the primary TSA fails, subsequent requests are routed to the next healthy server. Uses circuit breaker logic: after FailureThreshold consecutive failures, a TSA is marked unhealthy for RecoveryInterval before being retried.

public sealed class TsaPool
Inheritance
TsaPool
Inherited Members

Constructors

TsaPool(IEnumerable<string>, ILogger?)

Creates a TSA pool with the specified endpoints. The first endpoint is the primary; others are fallbacks in order.

public TsaPool(IEnumerable<string> tsaUrls, ILogger? logger = null)

Parameters

tsaUrls IEnumerable<string>

One or more TSA endpoint URLs.

logger ILogger

Optional logger.

Exceptions

ArgumentException

Thrown if no URLs are provided.

Properties

EndpointCount

Number of configured TSA endpoints.

public int EndpointCount { get; }

Property Value

int

FailureThreshold

Number of consecutive failures before a TSA is marked unhealthy. Default: 3.

public int FailureThreshold { get; init; }

Property Value

int

RecoveryInterval

Time a failed TSA stays unhealthy before being retried. Default: 60 seconds.

public TimeSpan RecoveryInterval { get; init; }

Property Value

TimeSpan

Methods

GetEndpointStatuses()

Returns the health status of all configured TSA endpoints.

public IReadOnlyList<TsaEndpointStatus> GetEndpointStatuses()

Returns

IReadOnlyList<TsaEndpointStatus>

GetTimestampAsync(ReadOnlyMemory<byte>, HashAlgorithmName, HttpClient, CancellationToken)

Requests a timestamp token, trying each healthy TSA in order until one succeeds.

public Task<byte[]> GetTimestampAsync(ReadOnlyMemory<byte> dataToTimestamp, HashAlgorithmName hashAlgorithm, HttpClient httpClient, CancellationToken cancellationToken = default)

Parameters

dataToTimestamp ReadOnlyMemory<byte>

Data to timestamp.

hashAlgorithm HashAlgorithmName

Hash algorithm for the timestamp request.

httpClient HttpClient

HTTP client for the requests.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<byte[]>

DER-encoded timestamp token.

Exceptions

InvalidOperationException

Thrown if all TSAs are unavailable.

ResetAll()

Resets all endpoints to healthy state.

public void ResetAll()