Add PKCS#11 startup self-test health reporting

This commit is contained in:
2026-10-14 13:49:38 +02:00
parent 8f2744afc7
commit b8a96330c0
13 changed files with 259 additions and 25 deletions

View File

@@ -15,11 +15,10 @@ public sealed class Pkcs11Options
public const string SectionName = "Crypt:Pkcs11";
/// <summary>
/// Absolute or resolvable file path of the PKCS#11 provider library.
/// Optional base directory that contains the <c>pkcs11</c> folder.
/// If null/empty, runtime uses the application base directory.
/// </summary>
[Required]
[MinLength(1)]
public required string LibraryPath { get; set; }
public string? AssetsRootPath { get; set; }
/// <summary>
/// Optional numeric slot identifier used to directly select the target token slot.
@@ -37,9 +36,23 @@ public sealed class Pkcs11Options
public string? ProxySocket { get; set; }
/// <summary>
/// Optional full path to <c>pkcs11-tool</c>, used by diagnostics and fallback paths.
/// Resolved absolute PKCS#11 proxy module path used at runtime.
/// Computed from <see cref="AssetsRootPath"/> and runtime defaults.
/// </summary>
public string? ToolPath { get; set; }
public string ResolvedLibraryPath { get; private set; } = string.Empty;
/// <summary>
/// Resolved absolute pkcs11-tool path used at runtime.
/// Computed from <see cref="AssetsRootPath"/> and runtime defaults.
/// Can be null when tool fallback is not available.
/// </summary>
public string? ResolvedToolPath { get; private set; }
public void SetResolvedPaths(string resolvedLibraryPath, string? resolvedToolPath)
{
ResolvedLibraryPath = resolvedLibraryPath;
ResolvedToolPath = resolvedToolPath;
}
/// <summary>
/// User PIN used to authenticate to the PKCS#11 token session.

View File

@@ -0,0 +1,10 @@
namespace EnvelopeGenerator.Application.Common.Dto;
public sealed record Pkcs11SelfTestStatusDto(
bool Completed,
bool Success,
string Mode,
string Summary,
DateTimeOffset? CheckedAtUtc,
string? InteropError,
string? ToolError);

View File

@@ -0,0 +1,8 @@
using EnvelopeGenerator.Application.Common.Dto;
namespace EnvelopeGenerator.Application.Common.Interfaces.Services;
public interface IPkcs11SelfTestStatusProvider
{
Pkcs11SelfTestStatusDto GetStatus();
}