Udap.Client 0.3.39

dotnet add package Udap.Client --version 0.3.39
NuGet\Install-Package Udap.Client -Version 0.3.39
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.3.39" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Udap.Client --version 0.3.39
#r "nuget: Udap.Client, 0.3.39"
#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.3.39

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

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 net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  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. 
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.3.39 29 5/1/2024
0.3.38 84 4/30/2024
0.3.37 165 4/11/2024
0.3.36 82 4/10/2024
0.3.35 174 4/9/2024
0.3.34 95 4/8/2024
0.3.33 111 4/7/2024
0.3.32 90 4/5/2024
0.3.31 97 4/4/2024
0.3.30 79 4/4/2024
0.3.29 135 4/3/2024
0.3.28 79 4/3/2024
0.3.27 94 4/2/2024
0.3.26 87 4/2/2024
0.3.25 80 4/2/2024
0.3.24 151 3/24/2024
0.3.22 189 3/6/2024
0.3.21 98 3/6/2024
0.3.20 96 3/5/2024
0.3.19 109 3/2/2024
0.3.18 99 3/2/2024
0.3.13 120 3/1/2024
0.3.12 92 2/24/2024
0.3.10 100 2/14/2024
0.3.8 168 2/11/2024
0.3.7 98 2/11/2024
0.3.6 91 2/10/2024
0.3.5 85 2/10/2024
0.3.4 80 2/10/2024
0.3.2 93 2/10/2024
0.3.0 254 1/31/2024
0.2.21 506 10/24/2023
0.2.20 116 10/23/2023
0.2.19 148 10/20/2023
0.2.18 155 10/11/2023
0.2.17 154 10/5/2023
0.2.16 212 9/21/2023
0.2.15 109 9/21/2023
0.2.14 165 9/20/2023
0.2.13 104 9/20/2023
0.2.12 125 9/20/2023
0.2.11 109 9/19/2023
0.2.10 191 9/13/2023
0.2.9 268 8/26/2023
0.2.8 147 8/18/2023
0.2.7 155 8/15/2023
0.2.6 139 8/12/2023
0.2.5 176 8/11/2023
0.2.4 154 8/10/2023
0.2.3 186 8/2/2023
0.2.2 158 8/1/2023
0.2.1 157 7/25/2023
0.2.0 218 7/16/2023
0.1.24 308 5/26/2023
0.1.23 139 5/22/2023
0.1.22 108 5/22/2023
0.1.21 128 5/21/2023
0.1.20 140 5/20/2023
0.1.17 145 5/9/2023
0.1.16 119 5/6/2023
0.1.15 133 5/4/2023
0.1.14 157 5/2/2023
0.1.12 125 5/1/2023
0.1.11 131 4/29/2023
0.1.9 131 4/29/2023
0.1.8 126 4/29/2023
0.1.7 156 4/28/2023
0.1.6 148 4/27/2023
0.1.5 156 4/27/2023
0.1.4 149 4/25/2023
0.1.3 168 4/23/2023
0.1.2 179 4/22/2023
0.1.1 203 4/22/2023
0.0.4-preview040 118 4/21/2023
0.0.4-preview039 94 4/13/2023
0.0.4-preview038 126 4/11/2023
0.0.4-preview037 105 4/7/2023
0.0.4-preview036 117 3/31/2023
0.0.4-preview035 104 3/31/2023
0.0.4-preview034 107 3/31/2023
0.0.4-preview033 125 3/30/2023
0.0.4-preview032 127 3/19/2023
0.0.4-preview029 123 3/18/2023
0.0.4-preview028 123 3/15/2023
0.0.4-preview027 110 3/13/2023
0.0.4-preview026 113 3/12/2023
0.0.4-preview025 126 3/10/2023
0.0.4-preview024 114 3/9/2023
0.0.4-preview022 137 3/9/2023
0.0.4-preview021 121 3/7/2023
0.0.4-preview020 136 3/7/2023
0.0.4-preview019 109 3/4/2023
0.0.4-preview018 137 3/4/2023
0.0.4-preview017 116 3/4/2023
0.0.4-preview016 119 3/1/2023
0.0.4-preview015 122 2/28/2023
0.0.4-preview014 134 2/23/2023
0.0.4-preview013 131 2/23/2023
0.0.4-preview012 150 2/21/2023
0.0.4-preview011 113 2/20/2023
0.0.4-preview010 124 2/20/2023
0.0.4-preview009 117 2/19/2023
0.0.4-preview008 139 2/14/2023
0.0.4-preview007 104 2/10/2023
0.0.4-preview006 124 2/8/2023
0.0.4-preview005 127 2/8/2023
0.0.4-preview004 116 2/7/2023
0.0.4-preview003 112 2/7/2023
0.0.4-preview002 114 2/7/2023
0.0.4-preview001 117 2/3/2023
0.0.4-preview000 113 2/2/2023
0.0.3-preview032 119 2/1/2023
0.0.3-preview031 108 2/1/2023
0.0.3-preview030 133 1/30/2023
0.0.3-preview029 123 1/21/2023
0.0.3-preview028 117 1/19/2023
0.0.3-preview027 129 1/18/2023
0.0.3-preview026 148 1/16/2023
0.0.3-preview025 116 1/15/2023
0.0.3-preview024 141 1/15/2023
0.0.3-preview020 131 1/15/2023
0.0.3-preview019 127 1/11/2023
0.0.3-preview018 137 1/11/2023
0.0.3-preview017 139 1/7/2023
0.0.3-preview016 118 1/7/2023
0.0.3-preview015 134 1/6/2023
0.0.3-preview014 131 1/6/2023
0.0.3-preview013 132 1/6/2023
0.0.3-preview012 133 1/6/2023
0.0.3-preview011 129 1/6/2023
0.0.3-preview010 142 1/3/2023
0.0.3-preview009 135 1/3/2023
0.0.3-preview008 138 1/2/2023
0.0.3-preview007 143 1/2/2023
0.0.3-preview006 120 1/2/2023
0.0.3-preview005 129 1/2/2023
0.0.3-preview004 138 1/1/2023
0.0.3-preview003 129 12/31/2022
0.0.3-preview002 174 12/28/2022
0.0.3-preview001 182 12/21/2022
0.0.3-preview000 132 11/29/2022
0.0.2-preview003 118 11/4/2022
0.0.2-preview002 132 11/4/2022
0.0.2-preview000 173 11/4/2022
0.0.1-preview002 158 11/4/2022
0.0.1-preview001 144 11/4/2022