Table of Contents

Class RsaKeyContainer

Namespace
Fdyay.IdentityServer.Services.KeyManagement
Assembly
Fdyay.IdentityServer.Core.dll

An RSA signing key plus its metadata. Holds RSAParameters (a value type) so the container itself owns no unmanaged resources; RSA instances are created on demand by RsaSecurityKey, which owns and disposes them.

public sealed class RsaKeyContainer : KeyContainer
Inheritance
RsaKeyContainer
Inherited Members

Constructors

RsaKeyContainer(RSAParameters, string, string, DateTime)

An RSA key from its parameters.

public RsaKeyContainer(RSAParameters parameters, string id, string algorithm, DateTime created)

Parameters

parameters RSAParameters

The key's parameters, private key included.

id string

The key id (kid).

algorithm string

The signing algorithm, such as RS256.

created DateTime

When the key was created (UTC).

Exceptions

ArgumentException

id or algorithm is null or empty.

Methods

Create(int, string, string, DateTime)

Generates a brand new RSA key of the given size.

public static RsaKeyContainer Create(int keySize, string algorithm, string id, DateTime created)

Parameters

keySize int
algorithm string
id string
created DateTime

Returns

RsaKeyContainer

ExportPrivateKey()

Exports the private key material as PKCS#1 DER bytes.

public byte[] ExportPrivateKey()

Returns

byte[]

FromPrivateKey(byte[], string, string, DateTime)

Creates a container from PKCS#1 DER private key bytes.

public static RsaKeyContainer FromPrivateKey(byte[] pkcs1PrivateKey, string id, string algorithm, DateTime created)

Parameters

pkcs1PrivateKey byte[]
id string
algorithm string
created DateTime

Returns

RsaKeyContainer

ToPublicJsonWebKey()

Produces the public JSON Web Key used for the JWKS and token validation.

public override JsonWebKey ToPublicJsonWebKey()

Returns

JsonWebKey

ToSecurityKey()

The key, private half included, as the token handler signs with it.

public override SecurityKey ToSecurityKey()

Returns

SecurityKey