refactor(CryptographParams): Aktualisierung, um TokenDeskriptoren mit Decryptoren zu initialisieren
This commit is contained in:
parent
87ad45f42a
commit
60ae8de550
@ -54,13 +54,19 @@ namespace DigitalData.Core.Security.Config
|
||||
if (!Directory.Exists(PemDirectory))
|
||||
Directory.CreateDirectory(PemDirectory);
|
||||
|
||||
foreach (var decryptor in Decryptors)
|
||||
var privateKeys = new List<RSAPrivateKey>();
|
||||
privateKeys.AddRange(Decryptors);
|
||||
privateKeys.AddRange(TokenDescriptors);
|
||||
if (VaultDecryptor is not null)
|
||||
privateKeys.Add(VaultDecryptor);
|
||||
|
||||
foreach (var privateKey in privateKeys)
|
||||
{
|
||||
// set default path
|
||||
if (decryptor.IsPemNull)
|
||||
if (privateKey.IsPemNull)
|
||||
{
|
||||
var file_name_params = new List<object> { decryptor.Issuer, decryptor.Audience, KeySizeInBits, DateTime.Now.ToTag(DateTagFormat) };
|
||||
if (decryptor.IsEncrypted)
|
||||
var file_name_params = new List<object> { privateKey.Issuer, privateKey.Audience, KeySizeInBits, DateTime.Now.ToTag(DateTagFormat) };
|
||||
if (privateKey.IsEncrypted)
|
||||
file_name_params.Add(Secrets.Version);
|
||||
|
||||
var file_name = $"{string.Join(FileNameSeparator, file_name_params)}.{FileExtension}";
|
||||
@ -68,14 +74,14 @@ namespace DigitalData.Core.Security.Config
|
||||
var path = Path.Combine(PemDirectory, file_name);
|
||||
|
||||
if (File.Exists(path))
|
||||
decryptor.SetPem(File.ReadAllText(path));
|
||||
privateKey.SetPem(File.ReadAllText(path));
|
||||
else
|
||||
{
|
||||
var pem = decryptor.IsEncrypted
|
||||
var pem = privateKey.IsEncrypted
|
||||
? Instance.RSAFactory.CreateEncryptedPrivateKeyPem(pbeParameters: PbeParameters, keySizeInBits: KeySizeInBits, password: Secrets.PBE_PASSWORD)
|
||||
: Instance.RSAFactory.CreatePrivateKeyPem(keySizeInBits: KeySizeInBits);
|
||||
|
||||
decryptor.SetPem(pem);
|
||||
privateKey.SetPem(pem);
|
||||
|
||||
// Save file in background
|
||||
Task.Run(async () => await File.WriteAllTextAsync(path: path, pem));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user