Skip to content

IJsonWebTokenSigner Interface

Defines the contract for JSON Web Signature (JWS) signing and verification services.

C#
public interface IJsonWebTokenSigner

Remarks

Part of the public JWT crypto surface alongside IJsonWebTokenCreator and IJsonWebTokenValidator. Signing is asynchronous and cancellable so the private-key operation can be served by an external key custodian (HSM/KMS/vault) over a network round-trip; the in-process path completes synchronously inside the task.

Methods

IJsonWebTokenSigner.SignAsync(JsonWebToken, JsonWebKey, CancellationToken) Method

Creates a signed JSON Web Signature (JWS) token.

C#
System.Threading.Tasks.Task<string> SignAsync(Abblix.Jwt.JsonWebToken token, Abblix.Jwt.JsonWebKey? signingKey, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

token JsonWebToken

The JSON Web Token to sign.

signingKey JsonWebKey

The signing key, or null for an unsigned ("alg": "none") token.

cancellationToken System.Threading.CancellationToken

Cancels a network-backed external signing round-trip.

Returns

System.Threading.Tasks.Task<System.String>
The JWS compact serialization string.

IJsonWebTokenSigner.ValidateAsync(string[], JsonWebTokenHeader, IAsyncEnumerable<JsonWebKey>, CancellationToken) Method

Validates the signature of a signed JWT.

C#
System.Threading.Tasks.Task<Abblix.Jwt.JwtValidationError?> ValidateAsync(string[] jwt, Abblix.Jwt.JsonWebTokenHeader header, System.Collections.Generic.IAsyncEnumerable<Abblix.Jwt.JsonWebKey> signingKeys, System.Threading.CancellationToken cancellationToken=default(System.Threading.CancellationToken));

Parameters

jwt System.String[]

The base64url-encoded JWT string parts (header, payload, signature).

header JsonWebTokenHeader

The JWT header.

signingKeys System.Collections.Generic.IAsyncEnumerable<JsonWebKey>

The signing keys to try for verification.

cancellationToken System.Threading.CancellationToken

Cancels enumeration of the signing-key source.

Returns

System.Threading.Tasks.Task<JwtValidationError>
A validation error if the signature is invalid; otherwise, null.