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
tsaUrlsIEnumerable<string>One or more TSA endpoint URLs.
loggerILoggerOptional logger.
Exceptions
- ArgumentException
Thrown if no URLs are provided.
Properties
EndpointCount
Number of configured TSA endpoints.
public int EndpointCount { get; }
Property Value
FailureThreshold
Number of consecutive failures before a TSA is marked unhealthy. Default: 3.
public int FailureThreshold { get; init; }
Property Value
RecoveryInterval
Time a failed TSA stays unhealthy before being retried. Default: 60 seconds.
public TimeSpan RecoveryInterval { get; init; }
Property Value
Methods
GetEndpointStatuses()
Returns the health status of all configured TSA endpoints.
public IReadOnlyList<TsaEndpointStatus> GetEndpointStatuses()
Returns
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
dataToTimestampReadOnlyMemory<byte>Data to timestamp.
hashAlgorithmHashAlgorithmNameHash algorithm for the timestamp request.
httpClientHttpClientHTTP client for the requests.
cancellationTokenCancellationTokenCancellation token.
Returns
Exceptions
- InvalidOperationException
Thrown if all TSAs are unavailable.
ResetAll()
Resets all endpoints to healthy state.
public void ResetAll()