Fix IKeyManager

Now correctly delete key folder while avoiding issues
This commit is contained in:
2021-06-07 16:12:20 +02:00
parent 8027229a7f
commit a3349e23c9
3 changed files with 17 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Threading.Tasks;
using Akari.Prototype.Server.Models;
using Akari.Prototype.Server.Utils;
using Microsoft.Extensions.Logging;
@@ -58,12 +59,19 @@ namespace Akari.Prototype.Server.Services
return true;
}
public void Clear(string applicationName)
public void Clear(Application application)
{
_logger.LogDebug($"Deleted keys for {applicationName}");
// Do it safely to avoid deleting unwanted files
File.Delete(GetMasterKeyPath(application.Name));
_logger.LogDebug($"Going to delete {GetKeyDirectoryPath(applicationName)}");
//Directory.Delete(GetKeyDirectoryPath(applicationName));
foreach (var fingerprint in application.Fingerprints)
{
File.Delete(GetKeyPath(application.Name, fingerprint));
}
Directory.Delete(GetKeyDirectoryPath(application.Name), recursive: false);
_logger.LogDebug($"Deleted keys for {application.Name}");
}
public bool Create(string applicationName)