Skip to content

TEFCA FHIR certificate profile presets - #79

Draft
JoeShook wants to merge 4 commits into
mainfrom
feature/62-tefca-presets
Draft

JoeShook wants to merge 4 commits into
mainfrom
feature/62-tefca-presets

Conversation

@JoeShook

@JoeShook JoeShook commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Closes #62

Depends on #76 (certificatePolicies) and #77 (NPI otherName). This branch merges both, so the diff includes their changes for now; it will shrink to the TEFCA commit once they merge.

What changed

New preset certificate profiles, following DirectTrust Certificate Profiles v2.1, Worksheet 4-4 (TEFCA RCE (UDAP)) and the Appendix validation profile. They live in Sigyll.Common/Services/TefcaCertificateProfiles.cs, and PresetProfiles() in Program.cs adds them next to Root CA, Intermediate CA, UDAP Client, SSL Server and the PQC presets.

Preset Details
TEFCA Intermediate CA RSA 4096, SHA-256, 5 years, pathLen 0, keyCertSign + cRLSign (critical), CDP + AIA
TEFCA FHIR Client / TEFCA FHIR Server OU RCE-FHIR; certificatePolicies 1.3.6.1.4.1.41179.0.2, .1.5, .3.1
TEFCA FHIR Client (Validation) / TEFCA FHIR Server (Validation) OU RCE-FHIR-TEST; no certificate policies

All four leaves: RSA 2048, SHA-256, 1095 days, keyUsage digitalSignature only (critical), basicConstraints cA=false (critical), no EKU, URI SAN required, RA approval required, no auto-issue. Subject template CN={UDAP URI}, OU=<ou>, O={Organization}, ST={State}, C=US. NPI is left off SubjectAltNameTypes because a listed type is required. The NPI otherName from #77 can still be added at issuance.

Seeding still adds any missing preset by name, so an existing database gets the five new rows once and later starts add nothing. No schema change.

Tests

  • dotnet build Sigyll.slnx: 0 warnings, 0 errors
  • dotnet test _tests/Sigyll.Signing.Tests: 607 passed, 17 skipped (PKCS Bump the microsoft group with 18 updates #11/SoftHSM), 0 failed
  • New TefcaCertificateProfilesTests (10 tests): checks the preset values, issues from a CSR with the production and validation leaf presets and checks KU/BC criticality, no EKU, SHA-256, URI + NPI SANs and the policies, and checks that a request without a URI SAN is rejected.

Open questions

  1. CN ≤ 64 characters and CN = one of the SAN URIs are not enforced. No profile constraint does this today. TEFCA SAN builder #65 (TEFCA SAN builder) already covers "CN: one of the SANs; error when none fits in 64 characters", so I left it to TEFCA SAN builder #65 rather than add a profile column here.
  2. "URIs only, no dNSName" is not enforced. SubjectAltNameTypes lists required types, not allowed ones. Enforcing it needs a new "allowed SAN types" constraint (column + migration + UI). Should that be a follow-up issue?
  3. Validity ≤ 3 years and RSA ≥ 2048 are defaults only. An operator can pass a later NotAfter, and nothing caps it at the profile's ValidityDays. The key size comes from the profile for server-generated keys, but a CSR's key size is not checked.
  4. CDP/AIA over http: the URLs come from the trust domain base URL (or the profile URL templates). The preset description says they must be http, but nothing enforces the scheme.
  5. Healthcare category policy (when an organization is asserted) is not in the presets. Operators clone the preset and add it. Should there be per-category presets?
  6. Validation leaves carry no policies. The spec allows them to omit policies. Should they carry the same three OIDs as production instead?
  7. No EKU on the leaves. EKU is optional in the profile. The existing UDAP Client preset uses clientAuth. Is that worth matching?

🤖 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>
Adds an NPI Subject Alternative Name type: an otherName with type-id
2.16.840.1.113883.4.6 and a UTF8String value holding the 10-digit NPI, as
the DirectTrust certificate profiles allow for a verified organization or
individual covered entity.

- SanType.Npi; profiles and SAN lists accept the "NPI" token, the RA API
  accepts "npi", and the issuance, external-request and CSR dialogs offer it.
- Validation: exactly 10 digits with a Luhn check digit computed over the
  80840 prefix (NpiNumber), both server-side in ValidateSanValues and in
  SanExtensionBuilder.
- Encoding via BouncyCastle in SanExtensionBuilder.
- Read back by CsrGenerationService.ExtractSubjectAltNames, so renewal,
  re-key, Similar and CSR generation keep the NPI; the explorer parses the
  stored "Npi:" entries when re-issuing.
- Display: SAN extensions containing an otherName are described from the
  decoded names (e.g. "Npi:1234567893") instead of the platform formatter;
  other SANs are shown as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Seed preset certificate profiles for TEFCA FHIR (RCE UDAP) certificates,
following DirectTrust Certificate Profiles v2.1, Worksheet 4-4 and the
Appendix validation profile:

- TEFCA Intermediate CA: pathLen 0, keyCertSign + cRLSign, CDP and AIA
- TEFCA FHIR Client / Server (production): OU RCE-FHIR, DirectTrust CP,
  IAL2 and Device policy OIDs
- TEFCA FHIR Client / Server (Validation): OU RCE-FHIR-TEST, no policies

Leaves are RSA 2048 / SHA-256, 1095 days, keyUsage digitalSignature
(critical), basicConstraints cA=false (critical), no EKU, URI SAN required
(an NPI otherName may be added), and require RA approval. Seeding adds
missing presets by name, so existing databases pick them up once.

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

Copy link
Copy Markdown
Owner Author

Scope addition from #76: certificate profiles should be able to configure certificatePolicies qualifiers (CPS URI and user notice), not only decode them for display. #76 ships OID-only policies; CertificatePolicyExtension.Build writes no qualifiers yet, so this PR extends the profile, the editor and Build to carry them.

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 FHIR certificate presets (intermediate, client, server; production and validation)

1 participant