fix(AsymCryptParams): Dateinamenerweiterung hinzugefügt.

This commit is contained in:
Developer 02
2024-12-17 14:06:09 +01:00
parent f38bad8531
commit b3629661a1
2 changed files with 12 additions and 2 deletions

View File

@@ -20,6 +20,8 @@ namespace DigitalData.Core.Security.Config
/// </example>
public string FileNameSeparator { get; init; } = "_-_";
public string FileExtension { get; init; } = "pem";
/// <summary>
/// Represents the separator used to concatenate the components of a key-related token string.
/// </summary>
@@ -55,7 +57,9 @@ namespace DigitalData.Core.Security.Config
if (decryptor.IsEncrypted)
file_name_params.Add(Secrets.Version);
var path = Path.Combine(PemDirectory, string.Join(FileNameSeparator, file_name_params));
var file_name = $"{string.Join(FileNameSeparator, file_name_params)}.{FileExtension}";
var path = Path.Combine(PemDirectory, file_name);
if (File.Exists(path))
decryptor.SetPem(File.ReadAllText(path));
@@ -65,7 +69,7 @@ namespace DigitalData.Core.Security.Config
? Instance.RSAFactory.CreateEncryptedPrivateKeyPem(pbeParameters: PbeParameters, keySizeInBits: KeySizeInBits, password: Secrets.PBE_PASSWORD)
: Instance.RSAFactory.CreatePrivateKeyPem(keySizeInBits: KeySizeInBits);
decryptor.SetPem(File.ReadAllText(pem));
decryptor.SetPem(pem);
// Save file in background
Task.Run(async () => await File.WriteAllTextAsync(path: path, pem));