Udap.Client 0.4.6

dotnet add package Udap.Client --version 0.4.6                
NuGet\Install-Package Udap.Client -Version 0.4.6                
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.4.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Udap.Client --version 0.4.6                
#r "nuget: Udap.Client, 0.4.6"                
#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.
// Install Udap.Client as a Cake Addin
#addin nuget:?package=Udap.Client&version=0.4.6

// Install Udap.Client as a Cake Tool
#tool nuget:?package=Udap.Client&version=0.4.6                

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. 
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.4.6 165 3/17/2025
0.4.5 419 3/4/2025
0.4.4 483 1/15/2025
0.4.3 71 1/14/2025
0.4.2 67 1/14/2025
0.4.1 239 1/13/2025
0.4.0 253 12/14/2024
0.3.96 328 11/6/2024
0.3.95 242 11/2/2024
0.3.94 141 10/31/2024
0.3.93 332 10/13/2024
0.3.92 117 10/13/2024
0.3.91 113 10/10/2024
0.3.89 144 10/10/2024
0.3.87 149 10/5/2024
0.3.86 165 10/5/2024
0.3.85 128 10/4/2024
0.3.84 120 10/3/2024
0.3.83 116 10/3/2024
0.3.82 176 9/20/2024
0.3.81 218 9/19/2024
0.3.80 167 9/19/2024
0.3.79 157 9/19/2024
0.3.78 152 9/19/2024
0.3.77 192 9/17/2024
0.3.76 122 9/17/2024
0.3.75 130 9/12/2024
0.3.74 123 9/12/2024
0.3.73 145 9/10/2024
0.3.72 296 9/7/2024
0.3.71 133 9/5/2024
0.3.70 127 9/5/2024
0.3.69 133 9/5/2024
0.3.68 152 9/4/2024
0.3.67 120 9/4/2024
0.3.66 115 9/4/2024
0.3.65 118 9/4/2024
0.3.64 122 9/2/2024
0.3.63 128 8/31/2024
0.3.62 144 8/29/2024
0.3.61 142 8/28/2024
0.3.60 200 8/2/2024
0.3.59 149 8/1/2024
0.3.58 113 8/1/2024
0.3.57 241 7/19/2024
0.3.56 126 7/19/2024
0.3.54 136 7/18/2024
0.3.53 143 7/15/2024
0.3.52 134 7/15/2024
0.3.51 135 7/12/2024
0.3.50 208 7/1/2024
0.3.49 144 7/1/2024
0.3.48 353 5/22/2024
0.3.47 244 5/15/2024
0.3.46 119 5/14/2024
0.3.45 190 5/12/2024
0.3.44 136 5/12/2024
0.3.43 108 5/12/2024
0.3.42 124 5/12/2024
0.3.41 194 5/6/2024
0.3.40 179 5/4/2024
0.3.39 139 5/1/2024
0.3.38 151 4/30/2024
0.3.37 221 4/11/2024
0.3.36 138 4/10/2024
0.3.35 263 4/9/2024
0.3.34 165 4/8/2024
0.3.33 161 4/7/2024
0.3.32 154 4/5/2024
0.3.31 153 4/4/2024
0.3.30 131 4/4/2024
0.3.29 186 4/3/2024
0.3.28 120 4/3/2024
0.3.27 137 4/2/2024
0.3.26 112 4/2/2024
0.3.25 166 4/2/2024
0.3.24 197 3/24/2024
0.3.22 247 3/6/2024
0.3.21 142 3/6/2024
0.3.20 145 3/5/2024
0.3.19 164 3/2/2024
0.3.18 155 3/2/2024
0.3.13 168 3/1/2024
0.3.12 136 2/24/2024
0.3.10 143 2/14/2024
0.3.8 220 2/11/2024
0.3.7 146 2/11/2024
0.3.6 144 2/10/2024
0.3.5 128 2/10/2024
0.3.4 134 2/10/2024
0.3.2 144 2/10/2024
0.3.0 295 1/31/2024
0.2.21 555 10/24/2023
0.2.20 153 10/23/2023
0.2.19 194 10/20/2023
0.2.18 202 10/11/2023
0.2.17 199 10/5/2023
0.2.16 268 9/21/2023
0.2.15 156 9/21/2023
0.2.14 216 9/20/2023
0.2.13 146 9/20/2023
0.2.12 166 9/20/2023
0.2.11 162 9/19/2023
0.2.10 234 9/13/2023
0.2.9 316 8/26/2023
0.2.8 190 8/18/2023
0.2.7 189 8/15/2023
0.2.6 177 8/12/2023
0.2.5 218 8/11/2023
0.2.4 194 8/10/2023
0.2.3 229 8/2/2023
0.2.2 196 8/1/2023
0.2.1 206 7/25/2023
0.2.0 253 7/16/2023
0.1.24 355 5/26/2023
0.1.23 175 5/22/2023
0.1.22 143 5/22/2023
0.1.21 175 5/21/2023
0.1.20 178 5/20/2023
0.1.17 183 5/9/2023
0.1.16 157 5/6/2023
0.1.15 174 5/4/2023
0.1.14 194 5/2/2023
0.1.12 164 5/1/2023
0.1.11 177 4/29/2023
0.1.9 173 4/29/2023
0.1.8 174 4/29/2023
0.1.7 205 4/28/2023
0.1.6 188 4/27/2023
0.1.5 198 4/27/2023
0.1.4 201 4/25/2023
0.1.3 215 4/23/2023
0.1.2 227 4/22/2023
0.1.1 248 4/22/2023
0.0.4-preview040 163 4/21/2023
0.0.4-preview039 138 4/13/2023
0.0.4-preview038 164 4/11/2023
0.0.4-preview037 149 4/7/2023
0.0.4-preview036 160 3/31/2023
0.0.4-preview035 142 3/31/2023
0.0.4-preview034 156 3/31/2023
0.0.4-preview033 164 3/30/2023
0.0.4-preview032 167 3/19/2023
0.0.4-preview029 160 3/18/2023
0.0.4-preview028 160 3/15/2023
0.0.4-preview027 150 3/13/2023
0.0.4-preview026 152 3/12/2023
0.0.4-preview025 158 3/10/2023
0.0.4-preview024 156 3/9/2023
0.0.4-preview022 181 3/9/2023
0.0.4-preview021 151 3/7/2023
0.0.4-preview020 179 3/7/2023
0.0.4-preview019 139 3/4/2023
0.0.4-preview018 176 3/4/2023
0.0.4-preview017 163 3/4/2023
0.0.4-preview016 144 3/1/2023
0.0.4-preview015 163 2/28/2023
0.0.4-preview014 168 2/23/2023
0.0.4-preview013 180 2/23/2023
0.0.4-preview012 193 2/21/2023
0.0.4-preview011 156 2/20/2023
0.0.4-preview010 152 2/20/2023
0.0.4-preview009 145 2/19/2023
0.0.4-preview008 184 2/14/2023
0.0.4-preview007 153 2/10/2023
0.0.4-preview006 164 2/8/2023
0.0.4-preview005 172 2/8/2023
0.0.4-preview004 139 2/7/2023
0.0.4-preview003 142 2/7/2023
0.0.4-preview002 158 2/7/2023
0.0.4-preview001 157 2/3/2023
0.0.4-preview000 156 2/2/2023
0.0.3-preview032 162 2/1/2023
0.0.3-preview031 156 2/1/2023
0.0.3-preview030 178 1/30/2023
0.0.3-preview029 168 1/21/2023
0.0.3-preview028 161 1/19/2023
0.0.3-preview027 179 1/18/2023
0.0.3-preview026 193 1/16/2023
0.0.3-preview025 146 1/15/2023
0.0.3-preview024 192 1/15/2023
0.0.3-preview020 171 1/15/2023
0.0.3-preview019 157 1/11/2023
0.0.3-preview018 181 1/11/2023
0.0.3-preview017 187 1/7/2023
0.0.3-preview016 168 1/7/2023
0.0.3-preview015 174 1/6/2023
0.0.3-preview014 166 1/6/2023
0.0.3-preview013 174 1/6/2023
0.0.3-preview012 181 1/6/2023
0.0.3-preview011 172 1/6/2023
0.0.3-preview010 194 1/3/2023
0.0.3-preview009 179 1/3/2023
0.0.3-preview008 183 1/2/2023
0.0.3-preview007 180 1/2/2023
0.0.3-preview006 166 1/2/2023
0.0.3-preview005 176 1/2/2023
0.0.3-preview004 182 1/1/2023
0.0.3-preview003 174 12/31/2022
0.0.3-preview002 222 12/28/2022
0.0.3-preview001 228 12/21/2022
0.0.3-preview000 175 11/29/2022
0.0.2-preview003 156 11/4/2022
0.0.2-preview002 169 11/4/2022
0.0.2-preview000 225 11/4/2022
0.0.1-preview002 200 11/4/2022
0.0.1-preview001 186 11/4/2022