diff --git a/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs b/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs index 8590139..f8d57ee 100644 --- a/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs +++ b/DigitalData.Core.Security/Cryptographer/RSACryptographer.cs @@ -1,4 +1,5 @@ using DigitalData.Core.Abstractions.Security; +using Microsoft.IdentityModel.Tokens; using System.Reflection; using System.Security.Cryptography; @@ -24,8 +25,15 @@ namespace DigitalData.Core.Security.Cryptographer public string Audience { get; init; } = string.Empty; + private readonly Lazy _lazyRsaSecurityKey; + + public RsaSecurityKey RsaSecurityKey => _lazyRsaSecurityKey.Value; + #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. - internal RSACryptographer() { } + internal RSACryptographer() + { + _lazyRsaSecurityKey = new(() => new RsaSecurityKey(RSA)); + } #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. } } \ No newline at end of file