Skip to content

TEFCA conformance check for issued certificates - #80

Draft
JoeShook wants to merge 4 commits into
mainfrom
feature/67-tefca-conformance
Draft

JoeShook wants to merge 4 commits into
mainfrom
feature/67-tefca-conformance

Conversation

@JoeShook

@JoeShook JoeShook commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Closes #67

Depends on #76 (certificate policies): this branch merges feature/63-certificate-policies so it can read policy OIDs with CertificatePolicyExtension. Merge #76 first; this diff will then shrink to this PR's own commits.

What changed

  • TefcaConformanceChecker (Sigyll.Common/Services/Tefca): checks an end-entity certificate and its issuing chain and returns named results (Pass / Fail / Warning / Skipped):
    • Subject OU: RCE-FHIR (production) or RCE-FHIR-TEST (validation). The environment can be given, or it is inferred from the OU; an unknown OU gets the production rules.
    • Chain is exactly root → intermediate → leaf (signatures verified, root self-signed, both CAs)
    • keyUsage is digitalSignature only and critical; basicConstraints is cA=false and critical
    • No dNSName SANs; CN ≤ 64 characters and equal to a SAN URI (ordinal, case-sensitive, no trimming). This applies to every role; for a server certificate the SAN URIs are its FHIR base URLs, with no exchange purpose expected.
    • Server certificates: no URI SAN ends with /. Server URI SANs are FHIR base URLs, and HL7 SSRAA 3.0.0 says a FHIR base URL SHALL NOT have a trailing slash. This fails for server profiles, warns when the role is unknown (for example an imported certificate), and is skipped for client profiles. The role comes from the profile's certificate type.
    • DirectTrust policy OIDs 1.3.6.1.4.1.41179.0.2, .1.5, .3.1 present (production only; skipped for validation)
    • CDP and AIA caIssuers present and plain http://
    • CDP/AIA reachable: runs only when an IUrlReachabilityProbe is supplied, so unit tests never touch the network
    • RSA ≥ 2048, sha256WithRSAEncryption, validity ≤ 3 years
    • SAN exchange purpose form: a pluggable ITefcaSanFormatRule, reported as a warning, never a failure, because the TEFCA client SAN form is not settled. The default rule accepts an authorized XP code as a fragment (#T-TRTMNT) or last path segment (/T-TRTMNT). It also accepts a query parameter (?{name}=T-TRTMNT), but only when a name is configured in TefcaConformance:ExchangePurposeQueryParameter. There is no default name. Server profiles skip this check (Skipped, with the reason), because their URI SANs are FHIR base URLs that never carry an exchange purpose. When the role is unknown, the result is still a warning.
  • URI handling follows HL7 SSRAA 3.0.0: URIs are compared as case-sensitive strings with no normalization. The SAN is split on its raw delimiters. Nothing is percent-decoded, case-folded or trimmed, and no System.Uri is involved. Parameter names compare ordinally, values are taken verbatim, and XP codes must match exactly. If the configured parameter appears more than once with conflicting values, the result is ambiguous (a warning).
  • TefcaConformanceService: runs the check on a stored end-entity certificate, taking the chain from the stored CAs and the role from its profile. It checks the operator (View). HttpUrlReachabilityProbe fetches URLs through the existing SigyllCrl outbound client. TefcaConformanceSettings binds the TefcaConformance configuration section.
  • After issuance: when the profile is TEFCA, IssueCertificateAsync and IssueCertificateFromCsrAsync run the check offline. They put the results on the new CertificateIssuanceResult.ConformanceResults and log failures. The check reports; it never blocks issuance. A profile counts as TEFCA when its name contains "TEFCA" (TefcaConformanceService.IsTefcaProfile). That is deliberately simple, so the preset profiles in TEFCA FHIR certificate presets (intermediate, client, server; production and validation) #62 can switch to a flag later.
  • Explorer: end-entity certificates get a "TEFCA Conformance" section with TEFCA Check (offline) and Check Online (also fetches the CDP/AIA URLs). Issuing from a TEFCA profile in the Explorer shows a toast summarizing the automatic check.

Overlap with #66 and #78

#66 adds an XP-from-SAN helper, and #78 is aligning its ExchangePurposeSan.Extract to the same SSRAA 3.0.0 rules (raw string, configured parameter name with no default, exact match, ambiguous duplicates). This PR depends on neither. Its own parser (TefcaExchangePurpose) is internal. Once those land, the default SAN rule can call the shared helper and the internal copy can go.

Testing

  • dotnet build Sigyll.slnx: succeeds

  • dotnet test _tests/Sigyll.Signing.Tests: 634 passed, 17 skipped (the PKCS Bump the microsoft group with 18 updates #11/SoftHSM tests, which skip without SoftHSM), 0 failed. TefcaConformanceTests covers:

    • each check passing and failing
    • the injected probe and the replaceable SAN rule
    • the SAN parser: fragment and path forms; the query form only with a configured name; ordinal names; no percent-decoding; exact case-sensitive XP match; identical and conflicting duplicates
    • ordinal CN matching
    • the trailing-slash check for server, unknown and client roles; server certificates skipping the SAN form while CN-equals-base-URL still applies; the SAN-form warning kept for an unknown role, including through server-profile issuance
    • the configured parameter name reaching the service
    • the issuance hook (TEFCA and non-TEFCA profiles)

    ServiceBoundaryTests covers the new service's operator check.

  • I did not exercise the Explorer UI in a browser.

Open questions

  • Profile identification: matching on the name is a stopgap. Should TEFCA FHIR certificate presets (intermediate, client, server; production and validation) #62's presets carry an explicit flag (needs a Flyway column), or a "trust framework" field?
  • RA API: the portal's CSR issuance endpoint does not return ConformanceResults yet. Should the results go into IssuanceApiResult?
  • Signature algorithm: only sha256WithRSAEncryption passes (RSA-PSS with SHA-256 fails). Is that the intended reading?

🤖 Generated with Claude Code

JoeShook and others added 4 commits November 20, 2026 16:37
A profile now carries a list of certificate policy OIDs (CertificatePolicyOids,
semicolon-delimited like the extended key usages). Issued certificates carry them
in a non-critical certificatePolicies extension (RFC 5280 section 4.2.1.4) on the
local, CSR, remote-signing and hybrid paths.

- CertificatePolicyExtension: parse, validate and normalize policy text, build the
  extension, and decode it (policy OIDs plus CPS / user notice qualifiers).
- Profile editor: a Certificate Policies field with inline OID validation; clone
  copies the policies; the service refuses entries that are not OIDs.
- Certificate viewer: the extension is decoded into its policy OIDs.
- Renewal and re-key keep the predecessor's policies: a profile may add policies
  but not drop any. Compatible-profile filtering and the issuance service both
  enforce this. Re-sign already copies every extension.
- Flyway V11 adds the CertificateProfiles.CertificatePolicyOids column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Checks an end-entity certificate against the TEFCA FHIR certificate profile
and returns one named pass/fail result per requirement: subject OU
(RCE-FHIR production, RCE-FHIR-TEST validation), a root -> intermediate ->
leaf chain, keyUsage digitalSignature only and critical, basicConstraints
cA=false and critical, no dNSName SANs, CN of at most 64 characters equal
to a SAN URI, the DirectTrust policy OIDs for production, http CDP and AIA
URLs (reachability through an injectable probe), RSA 2048+, SHA-256 with
RSA, and validity of at most three years.

The exchange purpose in the client SAN URI is not settled, so that check is
a replaceable rule that accepts a fragment, last path segment or xp query
carrying an authorized XP code, and reports anything else as a warning.

The check runs after an end-entity certificate is issued from a TEFCA
profile (its name contains "TEFCA"); the results ride on the issuance
result and a toast summarizes them. The Explorer runs it on demand for any
end-entity certificate, offline or with the CDP/AIA URLs fetched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…URLs

SAN URIs are read and compared as case-sensitive strings with no
normalization, following HL7 SSRAA 3.0.0: the exchange purpose parser splits
the raw SAN on its delimiters only, never percent-decodes or trims, and
matches XP codes exactly. Its query parameter name is now configuration
(TefcaConformance:ExchangePurposeQueryParameter) with no default; unset,
only the fragment and last-path-segment forms are recognized. A parameter
repeated with conflicting values is reported as ambiguous (a warning).

New check: a server certificate's URI SANs are FHIR base URLs, which SSRAA
3.0.0 says SHALL NOT end with a trailing slash. It fails for server
profiles, warns when the certificate's role is unknown, and is skipped for
client profiles. The role comes from the profile's certificate type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A server certificate's URI SANs are FHIR base URLs and never carry an
exchange purpose, so the SAN exchange purpose check is skipped for server
profiles, with that reason. The CN-equals-SAN-URI check still applies to
server certificates, against their base-URL SANs. When the role is unknown
the SAN form result stays a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JoeShook
JoeShook force-pushed the feature/67-tefca-conformance branch from f687dc6 to 25993ed Compare November 22, 2026 14:28
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.

TEFCA conformance check for issued certificates

1 participant