Skip to content

TEFCA: optional RCE-FHIR OU policy binding for certificates - #982

Draft
JoeShook wants to merge 2 commits into
developfrom
tefca/958-ou-binding
Draft

JoeShook wants to merge 2 commits into
developfrom
tefca/958-ou-binding

Conversation

@JoeShook

@JoeShook JoeShook commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

What changed

Opt-in subject OU policy binding for TEFCA certificates (DirectTrust Certificate Profiles v2.1, Worksheet 4-4 TEFCA RCE (UDAP) and its validation profile: RCE-FHIR for production, RCE-FHIR-TEST for validation). It is off by default, so current behaviour does not change.

  • Udap.Tefca.Server: new TefcaValidationOptions.RequiredCertificateOrganizationalUnits (Dictionary<string, HashSet<string>>, keyed by community name). When a community has a non-empty entry, x5c[0] must carry at least one of the listed subject OUs:
    • registration: the software statement's x5c[0] (context.ClientCertificate). If it fails: unapproved_software_statement
    • token endpoint: the client assertion's x5c[0]. If it fails: invalid_client
  • Udap.Client: new DiscoveryPolicy.RequiredSigningCertificateOrganizationalUnits (IDictionary<string, ICollection<string>>, keyed by community, mirroring the server option) with DiscoveryPolicy.GetRequiredSigningCertificateOrganizationalUnits(community), plus a virtual UdapClientDiscoveryValidator.ValidateSigningCertificateOrganizationalUnit(...). ValidateResource checks the server metadata signing certificate after trust chain validation, only when the community argument has a non-empty entry. Other communities and discoveries with no community are not checked, so one client can use the same policy for TEFCA and non-TEFCA servers (the client keeps the last policy it was given). If it fails, discovery returns an error ("Failed Signing Certificate Organizational Unit Validation").
  • Udap.Tefca.Model: TefcaConstants.OrganizationalUnits.Production / .Validation.
  • Udap.Util: X509Extensions.GetSubjectOrganizationalUnits() / HasSubjectOrganizationalUnit(...). These read every OU, including OUs inside multi-valued RDNs, through BouncyCastle X509Name. One match is enough. The comparison ignores case, following the X.520 caseIgnoreMatch rule for organizationalUnitName.
  • Udap.Tefca.Server README section, which notes that an OU entry for a community not in Communities is ignored.

All public API changes are additive.

How it was tested

The tests use certificates built in-test with CertificateRequest, because the generated test PKI does not carry these OUs.

  • UdapServer.Tests TefcaOrganizationalUnitPolicyTests (21 new tests), covering registration and token:
    • accepted with the OU, and when one of several OUs matches
    • rejected without the OU, and when x5c or the certificate is missing
    • production OU rejected in a validation-only community, and the validation OU rejected in a production community
    • no policy, or an empty set, means no check
    • DI/options wiring
  • Udap.Common.Tests SigningCertificateOrganizationalUnitTests (14 new tests): validator-level matrix plus end-to-end UdapClient.ValidateResource (trust chain stubbed). One test uses the same client and policy: TEFCA discovery enforces the OU, while a different community (and no community) passes with a certificate that lacks it. Run on both net8.0 and net10.0.
  • Results: dotnet test _tests/UdapServer.Tests --filter Validators.Tefca gave 74/74 passed. Udap.Common.Tests Client namespace (net10.0) gave 158/158 passed.

Open questions

  • Error codes: I used unapproved_software_statement at registration and invalid_client at the token endpoint, treating a certificate that fails the policy as a client authentication failure. The other TEFCA token rules use invalid_grant, so say if you'd rather be consistent with them.
  • OU comparison ignores case (X.520 caseIgnoreMatch). Should it be exact-case instead?
  • Assertions use xUnit Assert to match the existing TEFCA validator tests. Shouldly isn't referenced in this repo yet.

Closes #958

🤖 Generated with Claude Code

JoeShook and others added 2 commits November 20, 2026 16:46
DirectTrust Certificate Profiles v2.1 (Worksheet 4-4, TEFCA RCE (UDAP),
and its validation profile) require the subject organizationalUnitName
RCE-FHIR on production TEFCA FHIR certificates and RCE-FHIR-TEST on
validation certificates. The OU binds a certificate to TEFCA Facilitated
FHIR; the same CAs issue other certificates under the same anchors.

Opt-in, off by default:
- TefcaValidationOptions.RequiredCertificateOrganizationalUnits, keyed by
  community name. When a community has an entry, x5c[0] must carry one
  of the listed OUs: the software statement at registration
  (unapproved_software_statement) and the client assertion at the token
  endpoint (invalid_client).
- DiscoveryPolicy.RequiredSigningCertificateOrganizationalUnits applies
  the same check to the server metadata signing certificate in
  Udap.Client discovery.
- TefcaConstants.OrganizationalUnits.Production / .Validation.
- X509Extensions.GetSubjectOrganizationalUnits / HasSubjectOrganizationalUnit
  (any of several OUs may match; caseIgnoreMatch per X.520).

Tests use certificates built in-test, since the generated PKI does not
carry these OUs.

Closes #958

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One UdapClient can discover servers in several trust communities and keeps
the last policy it was given, so a single OU set would carry a TEFCA
requirement over to non-TEFCA discoveries.

DiscoveryPolicy.RequiredSigningCertificateOrganizationalUnits is now a
dictionary of community to accepted OUs, mirroring the server option. The
check runs only when the community passed to ValidateResource has a
non-empty entry; other communities, or no community, are not checked.
Adds DiscoveryPolicy.GetRequiredSigningCertificateOrganizationalUnits.

The Udap.Tefca.Server README notes that an OU entry for a community not in
Communities is ignored, and shows the client-side usage.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JoeShook
JoeShook force-pushed the tefca/958-ou-binding branch from 0b6a950 to b863c4d Compare November 22, 2026 14:28

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant