Table of Contents

Class X509KeyContainer

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

An RSA signing key wrapped in a self-signed certificate, for a relying party that wants x5c. Duende's X509KeyContainer, measured: subject CN= the issuer, SHA-256 with PKCS#1 padding, digital signature key usage and the server-authentication extended usage, valid from the key's creation for its retirement age.

public sealed class X509KeyContainer : KeyContainer
Inheritance
X509KeyContainer
Inherited Members

Constructors

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

A certificate-wrapped RSA key from its PKCS#12 bytes.

public X509KeyContainer(byte[] pkcs12, string id, string algorithm, DateTime created)

Parameters

pkcs12 byte[]

The certificate and its private key, as PKCS#12 with no password.

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.

ArgumentNullException

pkcs12 is null.

Properties

Certificate

The certificate, private key included.

public X509Certificate2 Certificate { get; }

Property Value

X509Certificate2

HasX509Certificate

Whether the key is wrapped in an X.509 certificate, published as x5c.

public override bool HasX509Certificate { get; }

Property Value

bool

Remarks

Always true.

Methods

Create(int, string, string, DateTime, string, TimeSpan)

Generates a new RSA key and its certificate.

public static X509KeyContainer Create(int keySize, string algorithm, string id, DateTime created, string issuer, TimeSpan certificateLifetime)

Parameters

keySize int
algorithm string
id string
created DateTime
issuer string
certificateLifetime TimeSpan

Returns

X509KeyContainer

ExportPkcs12()

The certificate and its private key, as PKCS#12 bytes with no password.

public byte[] ExportPkcs12()

Returns

byte[]

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