fix(RSAExtensions): Schlüssel in Dateinamen umbenennen
This commit is contained in:
@@ -19,7 +19,7 @@ namespace DigitalData.Core.Security.Extensions
|
||||
public static bool TryGetRSADecryptor(this ICryptFactory factory, string issuer, string audience, out IRSADecryptor? decryptor, Version? version = null, string? seperator = null)
|
||||
=> factory.TryGetRSADecryptor(factory.RSAKeyNameFormatter(issuer, audience, true, version, seperator), out decryptor);
|
||||
|
||||
private static string CreatePath(string key, string? directory = null)
|
||||
private static string CreatePath(string filename, string? directory = null)
|
||||
{
|
||||
directory ??= Environment.CurrentDirectory;
|
||||
|
||||
@@ -28,14 +28,14 @@ namespace DigitalData.Core.Security.Extensions
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
return Path.Combine(directory, $"{key}.pem");
|
||||
return Path.Combine(directory, $"{filename}.pem");
|
||||
}
|
||||
|
||||
private static readonly ConcurrentDictionary<string, SemaphoreSlim> FileLocks = new();
|
||||
|
||||
public static void SavePem(this IRSACryptographer decryptor, string key, string? directory = null)
|
||||
{
|
||||
var filePath = CreatePath(key : key, directory : directory);
|
||||
var filePath = CreatePath(filename: key, directory : directory);
|
||||
var fileLock = FileLocks.GetOrAdd(filePath, _ => new (1, 1));
|
||||
fileLock.Wait();
|
||||
try
|
||||
@@ -50,7 +50,7 @@ namespace DigitalData.Core.Security.Extensions
|
||||
|
||||
public static async Task SavePemAsync(this IRSACryptographer decryptor, string key, string? directory = null)
|
||||
{
|
||||
var filePath = CreatePath(key: key, directory: directory);
|
||||
var filePath = CreatePath(filename: key, directory: directory);
|
||||
var fileLock = FileLocks.GetOrAdd(filePath, _ => new (1, 1));
|
||||
await fileLock.WaitAsync();
|
||||
try
|
||||
|
||||
Reference in New Issue
Block a user