#### [Abblix\.Jwt](https://www.abblix.com/en/docs/api/abblix-jwt 'index')
### [Abblix\.Jwt](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt 'Abblix\.Jwt')

## IJsonWebTokenSigner Interface

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

```csharp
public interface IJsonWebTokenSigner
```

### Remarks
Part of the public JWT crypto surface alongside [IJsonWebTokenCreator](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.IJsonWebTokenCreator 'Abblix\.Jwt\.IJsonWebTokenCreator') and
[IJsonWebTokenValidator](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.IJsonWebTokenValidator 'Abblix\.Jwt\.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 {#Abblix.Jwt.IJsonWebTokenSigner.SignAsync(Abblix.Jwt.JsonWebToken,Abblix.Jwt.JsonWebKey,System.Threading.CancellationToken)}

Creates a signed JSON Web Signature \(JWS\) token\.

```csharp
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](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebToken 'Abblix\.Jwt\.JsonWebToken') {#Abblix.Jwt.IJsonWebTokenSigner.SignAsync(Abblix.Jwt.JsonWebToken,Abblix.Jwt.JsonWebKey,System.Threading.CancellationToken).token}

The JSON Web Token to sign\.

###### `signingKey` [JsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') {#Abblix.Jwt.IJsonWebTokenSigner.SignAsync(Abblix.Jwt.JsonWebToken,Abblix.Jwt.JsonWebKey,System.Threading.CancellationToken).signingKey}

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

###### `cancellationToken` [System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken') {#Abblix.Jwt.IJsonWebTokenSigner.SignAsync(Abblix.Jwt.JsonWebToken,Abblix.Jwt.JsonWebKey,System.Threading.CancellationToken).cancellationToken}

Cancels a network\-backed external signing round\-trip\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
The JWS compact serialization string\.

## IJsonWebTokenSigner\.ValidateAsync\(string\[\], JsonWebTokenHeader, IAsyncEnumerable\<JsonWebKey\>, CancellationToken\) Method {#Abblix.Jwt.IJsonWebTokenSigner.ValidateAsync(string[],Abblix.Jwt.JsonWebTokenHeader,System.Collections.Generic.IAsyncEnumerable_Abblix.Jwt.JsonWebKey_,System.Threading.CancellationToken)}

Validates the signature of a signed JWT\.

```csharp
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](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[\[\]](https://learn.microsoft.com/en-us/dotnet/api/system.array 'System\.Array') {#Abblix.Jwt.IJsonWebTokenSigner.ValidateAsync(string[],Abblix.Jwt.JsonWebTokenHeader,System.Collections.Generic.IAsyncEnumerable_Abblix.Jwt.JsonWebKey_,System.Threading.CancellationToken).jwt}

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

###### `header` [JsonWebTokenHeader](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebTokenHeader 'Abblix\.Jwt\.JsonWebTokenHeader') {#Abblix.Jwt.IJsonWebTokenSigner.ValidateAsync(string[],Abblix.Jwt.JsonWebTokenHeader,System.Collections.Generic.IAsyncEnumerable_Abblix.Jwt.JsonWebKey_,System.Threading.CancellationToken).header}

The JWT header\.

###### `signingKeys` [System\.Collections\.Generic\.IAsyncEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1')[JsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1') {#Abblix.Jwt.IJsonWebTokenSigner.ValidateAsync(string[],Abblix.Jwt.JsonWebTokenHeader,System.Collections.Generic.IAsyncEnumerable_Abblix.Jwt.JsonWebKey_,System.Threading.CancellationToken).signingKeys}

The signing keys to try for verification\.

###### `cancellationToken` [System\.Threading\.CancellationToken](https://learn.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken 'System\.Threading\.CancellationToken') {#Abblix.Jwt.IJsonWebTokenSigner.ValidateAsync(string[],Abblix.Jwt.JsonWebTokenHeader,System.Collections.Generic.IAsyncEnumerable_Abblix.Jwt.JsonWebKey_,System.Threading.CancellationToken).cancellationToken}

Cancels enumeration of the signing\-key source\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[JwtValidationError](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JwtValidationError 'Abblix\.Jwt\.JwtValidationError')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
A validation error if the signature is invalid; otherwise, null\.
