fix(Core.Security): pem-Importprozess in den Initilizer mehetods verschoben

This commit is contained in:
Developer 02
2024-11-18 17:14:42 +01:00
parent eccf2b32ce
commit 26a68cd477
3 changed files with 32 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
using DigitalData.Core.Abstractions.Security;
using DigitalData.Core.Security.Extensions;
using System.Runtime.Serialization;
namespace DigitalData.Core.Security
{
@@ -21,8 +22,26 @@ namespace DigitalData.Core.Security
}
}
public RSADecryptor()
public RSADecryptor() { }
public RSADecryptor(string pem, string? password = null)
{
Pem = pem;
Password = password;
Initialize();
}
[OnDeserialized]
private void OnDeserialized(StreamingContext context)
{
Initialize();
}
private void Initialize()
{
if (string.IsNullOrWhiteSpace(Pem))
throw new InvalidOperationException("Pem cannot be null or empty.");
if (Password is null)
_rsa.ImportFromPem(Pem);
else