Class KeyManager
- Namespace
- Fdyay.IdentityServer.Services.KeyManagement
- Assembly
- Fdyay.IdentityServer.Core.dll
Supports all classes in the .NET class hierarchy and provides low-level services to derived classes. This is the ultimate base class of all .NET classes; it is the root of the type hierarchy.
public sealed class KeyManager : IKeyManager, IDisposable
- Inheritance
-
KeyManager
- Implements
- Inherited Members
Remarks
One current key per algorithm in SigningAlgorithms, each rotated on its own schedule,
as Duende's KeyManager keeps them. Until 0.137.0 there was one RSA key for one algorithm.
Constructors
KeyManager(ISigningKeyStore, ISigningKeyProtector, TimeProvider, IOptions<IdentityServerOptions>, ILogger<KeyManager>)
A key manager over store.
public KeyManager(ISigningKeyStore store, ISigningKeyProtector protector, TimeProvider time, IOptions<IdentityServerOptions> options, ILogger<KeyManager> logger)
Parameters
storeISigningKeyStoreWhere the keys are persisted.
protectorISigningKeyProtectorWhat protects a key on its way into the store and back.
timeTimeProviderThe clock key ages are measured by.
optionsIOptions<IdentityServerOptions>The server's options; KeyManagement is validated here.
loggerILogger<KeyManager>Where key creation, deletion and unreadable keys are logged.
Exceptions
- InvalidOperationException
KeyManagement names a duplicate or unsupported signing algorithm, asks for a certificate-wrapped EC key, or sets a negative or zero duration where it may not.
Methods
Dispose()
Releases the lock that serializes key creation and rotation.
public void Dispose()
GetAllKeysAsync()
Gets all currently-published keys (for the JWKS and token validation).
public Task<IReadOnlyCollection<KeyContainer>> GetAllKeysAsync()
Returns
GetCurrentKeysAsync()
Gets the keys currently used for signing — one per configured algorithm — creating or rotating as needed. Duende's
GetCurrentKeysAsync.
public Task<IReadOnlyCollection<KeyContainer>> GetCurrentKeysAsync()
Returns
GetCurrentKeysAsync(CancellationToken)
The keys GetCurrentKeysAsync() answers, waiting for them no longer than the token allows. Duende's.
public Task<IReadOnlyCollection<KeyContainer>> GetCurrentKeysAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationToken
Returns
Remarks
Duende 8.0.1's arity, as an overload: changing the method above would break every host's key manager. A default interface method answering with GetCurrentKeysAsync(), so a host's key manager written before 0.162.0 keeps compiling and keeps signing — this server's key material service asks this one since 0.162.0. Duende's interface has no default.