Class DataProtectionKeyProtector
- Namespace
- Fdyay.IdentityServer.Services.KeyManagement
- Assembly
- Fdyay.IdentityServer.Core.dll
Protects signing key material at rest using ASP.NET Core Data Protection.
public sealed class DataProtectionKeyProtector : ISigningKeyProtector
- Inheritance
-
DataProtectionKeyProtector
- Implements
- Inherited Members
Remarks
Version 2, since 0.137.0, stores the key's kind with its private key — RSA as PKCS#1, EC as PKCS#8, a certificate-wrapped key as PKCS#12 — so every container comes back as itself; the kind travels inside Data, so a store's schema does not change. Version 1 held an RSA private key alone and is still read. Protected unless DataProtectKeys is off, as Duende's is.
Constructors
DataProtectionKeyProtector(IDataProtectionProvider, IOptions<IdentityServerOptions>?)
A protector drawing on provider.
public DataProtectionKeyProtector(IDataProtectionProvider provider, IOptions<IdentityServerOptions>? options = null)
Parameters
providerIDataProtectionProviderThe Data Protection provider the key material is protected with.
optionsIOptions<IdentityServerOptions>The server's options, whose DataProtectKeys decides whether keys are protected; null protects them.
Exceptions
- ArgumentNullException
provideris null.
Methods
Protect(KeyContainer)
Serializes and protects a key for storage.
public SerializedKey Protect(KeyContainer key)
Parameters
keyKeyContainer
Returns
Exceptions
- NotSupportedException
keyis not an RsaKeyContainer, EcKeyContainer or X509KeyContainer.
Unprotect(SerializedKey)
Unprotects and deserializes a stored key.
public KeyContainer Unprotect(SerializedKey key)
Parameters
keySerializedKey
Returns
Exceptions
- InvalidOperationException
The stored key holds no key, or a kind this server does not read.