Udap.Client 0.5.8

There is a newer version of this package available.
See the version list below for details.
dotnet add package Udap.Client --version 0.5.8
                    
NuGet\Install-Package Udap.Client -Version 0.5.8
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Udap.Client" Version="0.5.8" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Udap.Client" Version="0.5.8" />
                    
Directory.Packages.props
<PackageReference Include="Udap.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Udap.Client --version 0.5.8
                    
#r "nuget: Udap.Client, 0.5.8"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Udap.Client@0.5.8
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Udap.Client&version=0.5.8
                    
Install as a Cake Addin
#tool nuget:?package=Udap.Client&version=0.5.8
                    
Install as a Cake Tool

Udap.Client

UDAP logo

📦 Nuget Package: Udap.Client

Udap.Config simple dependency injection example configuration

If you chose to load a trust anchor yourself or non at all then registration can be a simple as the following.

builder.Services.AddScoped<TrustChainValidator>();
builder.Services.AddHttpClient<IUdapClient, UdapClient>();

The Udap.Client returns a UdapDiscoveryDocumentResponse . For convenience it contains a IsError property. If you need to understand why there is an error then you can investigate the Error, Exception, ErrorType, and HttpErrorReason depending on the reason for the error. There are also events you can subscribe to to get details about JWT and Certificate chaining errors. The Problem events come from the TrustChainValidator and are very useful. See example below.

var udapClient = serviceProvider.GetRequiredService<IUdapClient>();
var loggerFactory = serviceProvider.GetRequiredService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger(typeof(Program));

udapClient.Problem += element => logger.LogWarning(element.ChainElementStatus
    .Summarize(TrustChainValidator.DefaultProblemFlags));

udapClient.Untrusted += certificate2 => logger.LogWarning("Untrusted: " + certificate2.Subject);
udapClient.TokenError += message => logger.LogWarning("TokenError: " + message);

var response = await udapClient.ValidateResource(options.BaseUrl, trustAnchorStore, community);

if (response.IsError)
{
    logger.LogError(response.HttpErrorReason);
}
else
{
    logger.LogInformation(JsonSerializer.Serialize(
        response, 
        new JsonSerializerOptions{WriteIndented = true})); 
}

Experiment with this example code in the 1_UdapClientMetadata CLI Project

Example command line run: dotnet run --baseUrl https://fhirlabs.net/fhir/r4 --trustAnchor "C:\SureFhirLabs_CA.cer" --community udap://ECDSA/


NOTE The above example trust anchor (download) is used by most communities in the https://fhirlabs.net/fhir/r4 test server.


Udap.Client configuration with a ITrustAnchorStore implementation

Implement the ITrustAnchorStore to load trust anchors from a store. Below is dependency injection example of a file system store implementation. Note the CertStore folder in this project with anchors and intermediates folders. Also take note of the appsettings.json configuration. Notice each community has an Anchors and Intermediates collection of file references. In accompanying example project all communities issue certificates through a sub-certificate authority, yet the configuration only configured one Intermediate. Why is this? If the published certificate at the resource ./well-known/udap endpoint contains a AIA extension then the .NET X509Chain.Build method will follow the URL in the extension. This is true on Windows and Linux. Some Certificate Authorities may not follow this practice and you will have to configure for the intermediate certificate.


Note: An anchor must be chosen for each community. When you receive signed metadata the client will proceed to build a certificate chain from the first x5c header certificate and the anchor as the root certificate.


There is another way for intermediate certificates to be discovered. That is within the x5c header of the signed metadata. While the first certificate in the x5c header must be the signing certificate, the rest of the certificates may be the rest of the chain. But again you must have an anchor deliberately chosen and loaded into the client. The client will no load and trust an anchor from the x5c header.

<details><summary><a>View Metadata</></summary>

"UdapFileCertStoreManifest": {
  "Communities": [
    {
      "Name": "udap://stage.healthtogo.me/",
      "Anchors": [
        {
          "FilePath": "CertStore/anchors/EMRDirectTestCA.crt"
        }
      ]
    },
    {
      "Name": "udap://fhirlabs.net/",
      "Intermediates": [
        "CertStore/intermediates/SureFhirLabs_Intermediate.cer"
      ],
      "Anchors": [
        {
          "FilePath": "CertStore/anchors/SureFhirLabs_CA.cer"
        }
      ]
    },
    {
      "Name": "udap://expired.fhirlabs.net/",
      "Anchors": [
        {
          "FilePath": "CertStore/anchors/SureFhirLabs_CA.cer"
        }
      ]
    },
    {
      "Name": "udap://revoked.fhirlabs.net/",
      "Anchors": [
        {
          "FilePath": "CertStore/anchors/SureFhirLabs_CA.cer"
        }
      ]
    },
    {
      "Name": "udap://untrusted.fhirlabs.net/",
      "Anchors": [
        {
          "FilePath": "CertStore/anchors/SureFhirLabs_CA.cer"
        }
      ]
    },
    {
      "Name": "udap://Iss.Miss.Match.To.SubjAltName/",
      "Anchors": [
        {
          "FilePath": "CertStore/anchors/SureFhirLabs_CA.cer"
        }
      ]
    },
    {
      "Name": "udap://Iss.Miss.Match.To.BaseUrl//",
      "Anchors": [
        {
          "FilePath": "CertStore/anchors/SureFhirLabs_CA.cer"
        }
      ]
    },
    {
      "Name": "udap://ECDSA/",
      "Anchors": [
        {
          "FilePath": "CertStore/anchors/SureFhirLabs_CA.cer"
        }
      ]
    }
  ]
}

</details> <br/>

services.Configure<UdapFileCertStoreManifest>(context.Configuration.GetSection("UdapFileCertStoreManifest"));
services.AddSingleton<ITrustAnchorStore, TrustAnchorFileStore>();
services.AddScoped<TrustChainValidator>();
services.AddHttpClient<IUdapClient, UdapClient>();

Experiment with this example code in the 1_UdapClientMetadata CLI Project

Udap.Client advanced configuration

The TrustChainValidator a couple ways to control it's behavior when validating a chain. One is the control the Problem Flags identified in the .NET X509ChainStatusFlags settings. The defaults are recommended. Perhaps you are running some unit tests that do not publish a certificate revocation list. Then your code might look something like the following where we mask out OfflineRevocation and RevocationStatusUnknown flags.

services.Configure<UdapFileCertStoreManifest>(context.Configuration.GetSection("UdapFileCertStoreManifest"));
                    
var problemFlags = X509ChainStatusFlags.NotTimeValid |
                    X509ChainStatusFlags.Revoked |
                    X509ChainStatusFlags.NotSignatureValid |
                    X509ChainStatusFlags.InvalidBasicConstraints |
                    X509ChainStatusFlags.CtlNotTimeValid |
                    X509ChainStatusFlags.UntrustedRoot |
                    // X509ChainStatusFlags.OfflineRevocation |
                    X509ChainStatusFlags.CtlNotSignatureValid;
                    // X509ChainStatusFlags.RevocationStatusUnknown;

services.AddSingleton<ITrustAnchorStore, TrustAnchorFileStore>();
services.AddScoped<TrustChainValidator>(sp => new TrustChainValidator(new X509ChainPolicy(), problemFlags, sp.GetService<ILogger<TrustChainValidator>>()));
services.AddHttpClient<IUdapClient, UdapClient>();

TODO: Cover X509ChainPolicy

Udap.Client Dynamic Client Registration with a ICertificateStore implementation

Example projects

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Udap.Client:

Package Downloads
Udap.Server

Package is a part of the UDAP reference implementation for .NET.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.5.16 258 10/13/2025
0.5.15 226 10/12/2025
0.5.14 154 10/10/2025
0.5.13 167 10/10/2025
0.5.12 160 10/10/2025
0.5.11 172 10/10/2025
0.5.10 241 9/14/2025
0.5.9 237 8/19/2025
0.5.8 387 8/18/2025
0.5.7 249 8/8/2025
0.5.5 244 7/15/2025
0.5.4 240 7/14/2025
0.5.3 191 7/11/2025
0.5.2 234 7/10/2025
0.5.1 258 7/9/2025
0.5.0 221 7/6/2025
0.4.12 165 7/5/2025
0.4.11 367 6/13/2025
0.4.10 353 6/12/2025
0.4.9 386 6/12/2025
0.4.8 229 6/3/2025
0.4.7 343 4/18/2025
0.4.6 461 3/17/2025
0.4.5 581 3/4/2025
0.4.4 607 1/15/2025
0.4.3 196 1/14/2025
0.4.2 169 1/14/2025
0.4.1 331 1/13/2025
0.4.0 379 12/14/2024
0.3.96 428 11/6/2024
0.3.95 351 11/2/2024
0.3.94 240 10/31/2024
0.3.93 439 10/13/2024
0.3.92 206 10/13/2024
0.3.91 223 10/10/2024
0.3.89 246 10/10/2024
0.3.87 249 10/5/2024
0.3.86 254 10/5/2024
0.3.85 238 10/4/2024
0.3.84 205 10/3/2024
0.3.83 221 10/3/2024
0.3.82 276 9/20/2024
0.3.81 303 9/19/2024
0.3.80 288 9/19/2024
0.3.79 264 9/19/2024
0.3.78 243 9/19/2024
0.3.77 293 9/17/2024
0.3.76 224 9/17/2024
0.3.75 214 9/12/2024
0.3.74 243 9/12/2024
0.3.73 247 9/10/2024
0.3.72 407 9/7/2024
0.3.71 225 9/5/2024
0.3.70 209 9/5/2024
0.3.69 252 9/5/2024
0.3.68 262 9/4/2024
0.3.67 201 9/4/2024
0.3.66 195 9/4/2024
0.3.65 219 9/4/2024
0.3.64 232 9/2/2024
0.3.63 211 8/31/2024
0.3.62 236 8/29/2024
0.3.61 216 8/28/2024
0.3.60 272 8/2/2024
0.3.59 239 8/1/2024
0.3.58 197 8/1/2024
0.3.57 322 7/19/2024
0.3.56 217 7/19/2024
0.3.54 205 7/18/2024
0.3.53 251 7/15/2024
0.3.52 223 7/15/2024
0.3.51 216 7/12/2024
0.3.50 330 7/1/2024
0.3.49 241 7/1/2024
0.3.48 455 5/22/2024
0.3.47 334 5/15/2024
0.3.46 198 5/14/2024
0.3.45 273 5/12/2024
0.3.44 216 5/12/2024
0.3.43 223 5/12/2024
0.3.42 209 5/12/2024
0.3.41 308 5/6/2024
0.3.40 265 5/4/2024
0.3.39 240 5/1/2024
0.3.38 241 4/30/2024
0.3.37 316 4/11/2024
0.3.36 243 4/10/2024
0.3.35 356 4/9/2024
0.3.34 257 4/8/2024
0.3.33 282 4/7/2024
0.3.32 275 4/5/2024
0.3.31 244 4/4/2024
0.3.30 212 4/4/2024
0.3.29 271 4/3/2024
0.3.28 222 4/3/2024
0.3.27 233 4/2/2024
0.3.26 215 4/2/2024
0.3.25 261 4/2/2024
0.3.24 298 3/24/2024
0.3.22 335 3/6/2024
0.3.21 241 3/6/2024
0.3.20 226 3/5/2024
0.3.19 258 3/2/2024
0.3.18 273 3/2/2024
0.3.13 262 3/1/2024
0.3.12 246 2/24/2024
0.3.10 218 2/14/2024
0.3.8 301 2/11/2024
0.3.7 226 2/11/2024
0.3.6 223 2/10/2024
0.3.5 206 2/10/2024
0.3.4 224 2/10/2024
0.3.2 232 2/10/2024
0.3.0 392 1/31/2024
0.2.21 621 10/24/2023
0.2.20 226 10/23/2023
0.2.19 255 10/20/2023
0.2.18 278 10/11/2023
0.2.17 268 10/5/2023
0.2.16 337 9/21/2023
0.2.15 227 9/21/2023
0.2.14 279 9/20/2023
0.2.13 204 9/20/2023
0.2.12 233 9/20/2023
0.2.11 232 9/19/2023
0.2.10 323 9/13/2023
0.2.9 405 8/26/2023
0.2.8 274 8/18/2023
0.2.7 279 8/15/2023
0.2.6 268 8/12/2023
0.2.5 310 8/11/2023
0.2.4 306 8/10/2023
0.2.3 329 8/2/2023
0.2.2 289 8/1/2023
0.2.1 302 7/25/2023
0.2.0 341 7/16/2023
0.1.24 455 5/26/2023
0.1.23 269 5/22/2023
0.1.22 266 5/22/2023
0.1.21 292 5/21/2023
0.1.20 294 5/20/2023
0.1.17 288 5/9/2023
0.1.16 258 5/6/2023
0.1.15 313 5/4/2023
0.1.14 316 5/2/2023
0.1.12 269 5/1/2023
0.1.11 278 4/29/2023
0.1.9 306 4/29/2023
0.1.8 290 4/29/2023
0.1.7 313 4/28/2023
0.1.6 301 4/27/2023
0.1.5 325 4/27/2023
0.1.4 322 4/25/2023
0.1.3 342 4/23/2023
0.1.2 358 4/22/2023
0.1.1 353 4/22/2023
0.0.4-preview040 302 4/21/2023
0.0.4-preview039 261 4/13/2023
0.0.4-preview038 291 4/11/2023
0.0.4-preview037 245 4/7/2023
0.0.4-preview036 262 3/31/2023
0.0.4-preview035 270 3/31/2023
0.0.4-preview034 297 3/31/2023
0.0.4-preview033 297 3/30/2023
0.0.4-preview032 294 3/19/2023
0.0.4-preview029 266 3/18/2023
0.0.4-preview028 271 3/15/2023
0.0.4-preview027 252 3/13/2023
0.0.4-preview026 261 3/12/2023
0.0.4-preview025 288 3/10/2023
0.0.4-preview024 278 3/9/2023
0.0.4-preview022 312 3/9/2023
0.0.4-preview021 256 3/7/2023
0.0.4-preview020 315 3/7/2023
0.0.4-preview019 275 3/4/2023
0.0.4-preview018 285 3/4/2023
0.0.4-preview017 296 3/4/2023
0.0.4-preview016 272 3/1/2023
0.0.4-preview015 266 2/28/2023
0.0.4-preview014 296 2/23/2023
0.0.4-preview013 287 2/23/2023
0.0.4-preview012 309 2/21/2023
0.0.4-preview011 273 2/20/2023
0.0.4-preview010 267 2/20/2023
0.0.4-preview009 255 2/19/2023
0.0.4-preview008 305 2/14/2023
0.0.4-preview007 265 2/10/2023
0.0.4-preview006 270 2/8/2023
0.0.4-preview005 288 2/8/2023
0.0.4-preview004 260 2/7/2023
0.0.4-preview003 274 2/7/2023
0.0.4-preview002 291 2/7/2023
0.0.4-preview001 289 2/3/2023
0.0.4-preview000 270 2/2/2023
0.0.3-preview032 297 2/1/2023
0.0.3-preview031 303 2/1/2023
0.0.3-preview030 293 1/30/2023
0.0.3-preview029 308 1/21/2023
0.0.3-preview028 277 1/19/2023
0.0.3-preview027 290 1/18/2023
0.0.3-preview026 314 1/16/2023
0.0.3-preview025 254 1/15/2023
0.0.3-preview024 327 1/15/2023
0.0.3-preview020 288 1/15/2023
0.0.3-preview019 307 1/11/2023
0.0.3-preview018 310 1/11/2023
0.0.3-preview017 337 1/7/2023
0.0.3-preview016 324 1/7/2023
0.0.3-preview015 301 1/6/2023
0.0.3-preview014 280 1/6/2023
0.0.3-preview013 291 1/6/2023
0.0.3-preview012 313 1/6/2023
0.0.3-preview011 314 1/6/2023
0.0.3-preview010 311 1/3/2023
0.0.3-preview009 302 1/3/2023
0.0.3-preview008 304 1/2/2023
0.0.3-preview007 292 1/2/2023
0.0.3-preview006 303 1/2/2023
0.0.3-preview005 302 1/2/2023
0.0.3-preview004 315 1/1/2023
0.0.3-preview003 285 12/31/2022
0.0.3-preview002 339 12/28/2022
0.0.3-preview001 346 12/21/2022
0.0.3-preview000 305 11/29/2022
0.0.2-preview003 282 11/4/2022
0.0.2-preview002 304 11/4/2022
0.0.2-preview000 362 11/4/2022
0.0.1-preview002 314 11/4/2022
0.0.1-preview001 299 11/4/2022