Egov.Extensions.WalletValidation
10.0.7
Prefix Reserved
See the version list below for details.
dotnet add package Egov.Extensions.WalletValidation --version 10.0.7
NuGet\Install-Package Egov.Extensions.WalletValidation -Version 10.0.7
<PackageReference Include="Egov.Extensions.WalletValidation" Version="10.0.7" />
<PackageVersion Include="Egov.Extensions.WalletValidation" Version="10.0.7" />
<PackageReference Include="Egov.Extensions.WalletValidation" />
paket add Egov.Extensions.WalletValidation --version 10.0.7
#r "nuget: Egov.Extensions.WalletValidation, 10.0.7"
#:package Egov.Extensions.WalletValidation@10.0.7
#addin nuget:?package=Egov.Extensions.WalletValidation&version=10.0.7
#tool nuget:?package=Egov.Extensions.WalletValidation&version=10.0.7
Wallet Validation
A reusable .NET library for creating OpenID4VP mdoc authorization requests and validating
encrypted wallet presentations. X.509 trust and revocation
checks are provided by Egov.Extensions.CertificateValidation through NuGet and certificate
loading provided by Egov.Extensions.Configuration.
Prerequisites and installation
.NET 10.0 and the ASP.NET Core shared framework are required. The verifier needs an ECDSA P-256 certificate with a private key, and trusted issuer/status-list root certificates.
dotnet add package Egov.Extensions.WalletValidation
Configuration
Add a section to appsettings.json. Supply certificate passwords through your application's
secret configuration provider.
{
"WalletValidation": {
"CertificatePath": "Files/Certificates/verifier.pfx",
"CustomTrustPaths": ["Files/Certificates/TrustedWalletIssuers"],
"RevocationMode": "Online",
"StatusValidationMode": "Online",
"StatusMaxAge": "1.00:00:00",
"StatusValidationClockSkew": "00:00:15"
}
}
Register the validator and its dependencies in Program.cs:
using Microsoft.Extensions.DependencyInjection;
builder.Services.AddWalletValidatorWithDependencies(
builder.Configuration.GetSection("WalletValidation"));
Or configure it in code:
builder.Services.AddWalletValidatorWithDependencies(options =>
{
options.CertificatePath = "Files/Certificates/verifier.pfx";
options.CustomTrustPaths = ["Files/Certificates/TrustedWalletIssuers"];
});
Registration includes logging, a default TimeProvider, HTTP clients, a distributed memory
cache, WalletValidator, and IStatusListChecker. An existing TimeProvider,
IDistributedCache or IStatusListChecker registration is preserved. Register a shared
distributed cache first when running multiple application instances.
Options reference
| Option | Default | Purpose |
|---|---|---|
CertificatePath |
Unset | PFX/PKCS#12 file or directory containing tls.crt and tls.key. |
CertificatePassword |
Unset | Password for the certificate/private key, if encrypted. |
Certificate |
Unset | Code-only alternative: a verifier certificate with its private key. |
IntermediateCertificates |
Unset | Code-only intermediate chain for the request's x5c; populated when loaded from a chain bundle. |
CustomTrustPaths |
Unset | Trusted root files/folders for issuer and status-list certificates. Folders use *.cer/*.crt. |
RevocationMode |
Online |
X.509 certificate revocation mode: Online, Offline or NoCheck. |
IssuerQualifiedCertificate |
Unset | ETSI qualified certificate statements required on issuer (document signer) certificates, e.g. { "QcType": "0.4.0.194126.1.1" } for PID providers. RequireQcCompliance defaults to true. Unset skips the check. |
StatusValidationMode |
Online |
Credential status checking: Online or NoCheck. |
StatusMaxAge |
24 hours | Maximum status list token age, counted from its issued-at claim. Older tokens are rejected even without or before their expiration, so an old list cannot be replayed. |
StatusValidationClockSkew |
15 seconds | Tolerance for issued-at and not-before claims. Expiration remains strict. |
DeviceEngagementUrlFormat |
eudi-openid4vp://?client_id={0}&request_uri={1}&request_uri_method=post |
URL format with escaped client ID and request URI placeholders. |
Post-configuration loads the verifier certificate through Egov.Extensions.Configuration
and rejects a missing certificate or one without a private key. Request signing requires
ECDSA P-256. WalletValidatorOptions.Dispose() disposes its verifier and intermediate
certificates, including directly assigned certificates; coordinate ownership if sharing them.
The full registration uses custom root trust and disables certificate downloads. Configure
trusted roots explicitly. Its issuer policy requires a digital-signature leaf certificate,
the mdoc document-signer EKU (1.0.18013.5.1.2), a CRL distribution-point extension,
a maximum validity of 457 days, and an issuer CA path-length constraint of zero.
It enables RequireExplicitApplicationPolicy from CertificateValidation 10.0.5, so the
leaf EKU extension must explicitly contain mdlDS; an absent EKU or anyExtendedKeyUsage alone fails.
Leaf and root countries must match; states must match when both are present.
The status-list policy also limits validity and issuer path length, but currently does not
require a status-list-specific EKU. Qualified-certificate/QcType checks are not enabled
by default. Override these policies for your deployment's certificate profile.
Custom certificate policies
For complete control, register issuer and status-list policies separately, then the wallet
validator. Both action and IConfiguration overloads are available:
using System.Security.Cryptography.X509Certificates;
builder.Services.AddWalletCertificateValidator(options =>
{
options.TrustMode = X509ChainTrustMode.CustomRootTrust;
options.CustomTrustPaths = ["Files/Certificates/TrustedWalletIssuers"];
options.DisableCertificateDownloads = true;
options.KeyUsages = X509KeyUsageFlags.DigitalSignature;
options.ApplicationPolicy = ["1.0.18013.5.1.2"];
options.RequireExplicitApplicationPolicy = true;
});
builder.Services.AddWalletStatusListValidator(options =>
{
options.TrustMode = X509ChainTrustMode.CustomRootTrust;
options.CustomTrustPaths = ["Files/Certificates/TrustedStatusListSigners"];
options.DisableCertificateDownloads = true;
options.KeyUsages = X509KeyUsageFlags.DigitalSignature;
});
builder.Services.AddWalletValidator(
builder.Configuration.GetSection("WalletValidation"));
The service keys/options names are WalletIssuer and WalletStatusList.
AddWalletValidator applies wallet revocation mode and, when specified, wallet custom
trust paths to both policies and adds the issuer subject-location check. It requires the
two policy registrations or equivalent custom services. AddWalletStatusListValidator
can also be used alone; it supplies HTTP, cache, clock and logging dependencies.
For further rules, configure named CertificateValidationOptions after registration.
The custom configuration path leaves application-policy and EKU requirements to the caller.
To require an explicit mdlDS issuer EKU, configure both ApplicationPolicy = ["1.0.18013.5.1.2"]
and RequireExplicitApplicationPolicy = true, as shown above. AddWalletValidator does not
add that OID or enable the flag automatically; AddWalletValidatorWithDependencies does.
Creating a request
Inject WalletValidator. Use the wallet metadata and nonce received when the wallet
retrieves your authorization request. Build a DCQL query for the required claims:
using Egov.Extensions.WalletValidation;
using Egov.Extensions.WalletValidation.OpenId4Vp;
const string queryId = "pid";
const string docType = "eu.europa.ec.eudi.pid.1";
var query = new DcqlQuery
{
Credentials = [new CredentialQuery
{
Id = queryId,
Format = "mso_mdoc",
Meta = new CredentialQueryMeta { DocTypeValue = docType },
Claims = [new CredentialQueryClaim { Path = [docType, "family_name"] }]
}]
};
var request = validator.CreateMdocRequest(
walletMetadata, walletNonce, transactionId, query, responseUri,
state: expectedState);
// Return request.AuthorizationRequestJws to the wallet.
// Retain request.ValidatorNonce and request.EphemeralKey server-side for this transaction.
The request is signed with ES256 and contains the verifier's x5c chain, an x509_hash:
client ID, a fresh 128-bit nonce and a public P-256 response encryption key whose kid
is the transaction ID. It requests direct_post.jwt responses encrypted with ECDH-ES
and A256GCM. Optional verifierInfo and transactionData are supported.
To build the wallet engagement URL, inject IOptions<WalletValidatorOptions> and use
options.Value.BuildDeviceEngagementUrl(requestUri).
Validating a response
Read the wallet's encrypted response form field at your response endpoint, restore
the original transaction data, and call:
var result = await validator.VerifyMdocResponseAsync(
authorizationResponseJwe,
queryId,
docType,
transactionId,
request.ValidatorNonce,
responseUri,
request.EphemeralKey,
cancellationToken);
if (result.IsWalletError)
{
// For example, access_denied means the user declined to share a document.
// Check result.State against retained application state when applicable.
logger.LogInformation("Wallet reported {Error}: {Description}", result.Error, result.ErrorDescription);
return;
}
if (!result.IsValid)
{
logger.LogWarning("Wallet rejected: {Code}: {Message}", result.Error, result.ErrorDescription);
return;
}
var document = result.Document;
var returnedState = result.State;
The validator checks response nonce/key binding, decrypts the JWE, selects exactly one
credential for the query ID, parses its mdoc, verifies issuer-signed value digests and
MSO validity, authenticates issuer and device signatures, validates the issuer certificate,
and checks credential status when enabled and MSO.status is present. An absent status
is accepted; a present status must contain a complete, valid status-list reference.
Issuer-certificate revocation checks still follow the configured certificate policy.
Failures return IsValid = false, a
machine-readable Error and an optional ErrorDescription. Caller cancellation during
status retrieval propagates as cancellation.
Encrypted wallet errors return IsValid = false and IsWalletError = true, with the
wallet's original Error, optional ErrorDescription and State. They are recognized
only after authenticated decryption with the retained transaction key.
The application owns transaction storage, expiry, single-use/replay prevention, state comparison and authorization based on returned claims. It must check required claims were disclosed and meet its business rules; this API receives the query ID and document type, rather than the full original DCQL query. Keep the ephemeral private key server-side and erase it when the transaction is consumed or expires.
Status lists and supported formats
IStatusListChecker.CheckAsync(uri, index, trustedCertificates, clockSkew, cancellationToken)
also works independently. It accepts signed JWT (statuslist+jwt, ES256 with x5c)
and COSE/CWT (application/statuslist+cwt, ECDSA with x5chain) responses. It validates
signatures, certificate trust, subject, time claims and positive TTL when provided.
Lists may use 1, 2, 4 or 8 bits per entry; zero is valid and any nonzero status is invalid.
StatusCheckResult.IsSuccessful distinguishes retrieval/validation failure from a
successful check of an invalid credential; IsValid holds the status outcome.
Validated lists are cached until token expiry, with refresh governed by TTL or a default
interval. Without exp, expiry defaults to six hours and refresh to one hour. On a failed
HTTP refresh, an unexpired validated list may be reused. Cache entries separate URIs,
per-call trust stores and clock-skew values. Invalid tokens are never cached.
Presentation validation handles mdoc version 1.0 with ECDSA issuer/device signatures. It does not validate SD-JWT VC presentations, device MAC authentication, or multiple credentials for a single query ID. Serialization models expose additional wire fields for integration; their availability does not imply validation of every format.
Building, testing and packaging
dotnet restore src/Egov.Extensions.WalletValidation.slnx
dotnet build src/Egov.Extensions.WalletValidation.slnx --configuration Release --no-restore
dotnet test src/Egov.Extensions.WalletValidation.slnx --configuration Release --no-build
dotnet pack src/Egov.Extensions.WalletValidation/Egov.Extensions.WalletValidation.csproj --configuration Release --output artifacts /p:Version=10.0.5
Tests generate disposable certificates and signed JWT/COSE/JWE payloads, use a controllable clock and HTTP fixtures, and require no live wallet, production keys or network services.
The workflow starts explicitly through Run workflow, builds and tests the solution,
and publishes from main to NuGet.org and GitHub Packages after validation. CI assigns
10.0.<run_number> and passes it to build and pack. For local packaging, supply the
desired version with /p:Version, as shown above.
Configure the repository's NUGET_API_KEY secret before publishing; GitHub Packages uses
the workflow token with packages: write.
Contributing and license
See CHANGELOG.md, CONTRIBUTING.md and CODE_OF_CONDUCT.md. Licensed under MIT; see 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
- Egov.Extensions.CertificateValidation (>= 10.0.16)
- Egov.Extensions.Configuration (>= 10.0.5)
- jose-jwt (>= 5.3.0)
- System.Security.Cryptography.Cose (>= 10.0.15)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.