Egov.Extensions.CertificateValidation
10.0.17
Prefix Reserved
dotnet add package Egov.Extensions.CertificateValidation --version 10.0.17
NuGet\Install-Package Egov.Extensions.CertificateValidation -Version 10.0.17
<PackageReference Include="Egov.Extensions.CertificateValidation" Version="10.0.17" />
<PackageVersion Include="Egov.Extensions.CertificateValidation" Version="10.0.17" />
<PackageReference Include="Egov.Extensions.CertificateValidation" />
paket add Egov.Extensions.CertificateValidation --version 10.0.17
#r "nuget: Egov.Extensions.CertificateValidation, 10.0.17"
#:package Egov.Extensions.CertificateValidation@10.0.17
#addin nuget:?package=Egov.Extensions.CertificateValidation&version=10.0.17
#tool nuget:?package=Egov.Extensions.CertificateValidation&version=10.0.17
Egov.Extensions.CertificateValidation
An extensible X.509 certificate validator for .NET, wrapping X509Chain with a declarative, configuration-driven policy.
Installation
dotnet add package Egov.Extensions.CertificateValidation
Usage
1. Register the validator
builder.Services.AddCertificateValidator(builder.Configuration.GetSection("CertificateValidation"));
2. Configure
{
"CertificateValidation": {
"ExtraPaths": [ "Files/Certificates/Intermediates" ],
"RevocationMode": "Online",
"RevocationFlag": "ExcludeRoot",
"AllowedCommonNames": [ "*.egov.md" ],
"Cryptography": { "AllowedSignatureAlgorithms": [ "1.2.840.113549.1.1.11", "1.2.840.113549.1.1.12" ] },
"MaxValidity": "825.00:00:00",
"KeyUsages": "DigitalSignature"
}
}
3. Validate
public sealed class MyService(ICertificateValidator validator)
{
public bool Check(X509Certificate2 certificate)
{
var result = validator.Validate(certificate);
if (!result.IsValid)
{
// result.ErrorDescription is non-null whenever IsValid is false
logger.LogWarning("Certificate rejected: {Reason}", result.ErrorDescription);
}
return result.IsValid;
}
}
Keyed validators
Register several independently configured validators and resolve them by key:
builder.Services.AddCertificateValidator("mpass", builder.Configuration.GetSection("MPassCertificateValidation"));
builder.Services.AddCertificateValidator("msign", builder.Configuration.GetSection("MSignCertificateValidation"));
public sealed class MPassService([FromKeyedServices("mpass")] ICertificateValidator validator);
Each registered policy is validated when the host starts. Invalid values are reported together in
one OptionsValidationException.
What can be validated
Beyond standard chain building, revocation and time validity, including custom trust anchors
that are not self-signed roots (e.g. issuing CAs from an ETSI trusted list), the options cover
allowed names and SHA-1/SHA-256 thumbprints, signature algorithms, maximum validity period,
key usages, end-entity enforcement, application and certificate policies,
mandatory and forbidden extensions, issuer-level constraints, eIDAS qualified
certificate statements (qcStatements) and Certificate Transparency SCTs
(RFC 6962), plus a custom validation callback.
See the full documentation for the complete option reference.
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Egov.Extensions.CertificateValidation:
| Package | Downloads |
|---|---|
|
Egov.Extensions.WalletValidation
OpenID4VP mdoc request creation and wallet response validation for .NET, including issuer and device authentication, X.509 certificate validation and JWT/CWT credential status lists. |
GitHub repositories
This package is not used by any popular GitHub repositories.