Skip to content

NPI otherName SAN entries - #77

Merged
JoeShook merged 2 commits into
mainfrom
feature/64-npi-othername
Nov 22, 2026
Merged

JoeShook merged 2 commits into
mainfrom
feature/64-npi-othername

Conversation

@JoeShook

@JoeShook JoeShook commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Closes #64

What changed

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.

  • Request model: SanType.Npi (appended to the enum, so existing values keep their numbers). Profiles' SubjectAltNameTypes and SAN lists accept the NPI token; the RA API (MapSan) accepts npi; the portal's SAN type list includes Npi.
  • Issuance UI: the issuance, external-request and CSR dialogs list NPI (they enumerate SanType), with a placeholder and client-side check. Certificate Profiles gets an NPI SAN-type checkbox, and the SAN Lists editor offers NPI.
  • Validation: new NpiNumber helper: exactly 10 digits, last digit = Luhn check digit computed over the first nine with the 80840 prefix. Enforced in IssuanceValidator.ValidateSanValues (server side, all issuance paths) and in SanExtensionBuilder.Build.
  • Encoding: SanExtensionBuilder writes otherName ::= SEQUENCE { 2.16.840.1.113883.4.6, [0] EXPLICIT UTF8String } via BouncyCastle.
  • Re-issue: CsrGenerationService.ExtractSubjectAltNames now returns NPI entries, so renewal/re-key identity checks, CSR generation and external requests keep them. Issued certs store SANs as Npi:<digits>; the explorer parses Npi: when seeding renew / re-key / Similar.
  • Viewer display: new SubjectAltNameText.Describe. When a SAN extension holds an otherName, it is described from the decoded names (Npi:1234567893, Dns:…, OtherName:<oid>=… for other otherNames), because the platform formatter renders otherName as hex / <unsupported>. SANs without an otherName are formatted exactly as before. The folder-import path (CertificateImportService) uses decoded names when an NPI is present (its byte scan would misread the NPI OID bytes).

No database migration is needed: SubjectAltNameTypes and SanList.Items are free text.

Testing

  • dotnet build Sigyll.slnx: succeeded.
  • dotnet test _tests/Sigyll.Signing.Tests: 571 passed, 17 skipped (PKCS Bump the microsoft group with 18 updates #11/SoftHSM), 0 failed.
  • New NpiSanTests: check-digit accept/reject cases, length and character rules, validator and token parsing, DER encoding (OID, explicit [0], UTF8String), read-back from a certificate, display text, and that SANs without an otherName keep platform formatting.
  • New CsrIssuanceTests: issuance with an NPI SAN (encoded as otherName, stored as Dns:…;Npi:…) and rejection of a bad check digit.
  • Not exercised by hand in the running UI.

Open questions

  • Dropdowns show the enum name (Npi, like the existing IpAddress). Should they show NPI instead?
  • Should a profile be able to require NPI (the checkbox does that, same as the other SAN types), or should NPI only ever be optional?
  • The portal's CsrParser still only picks up DNS/IP SANs from an uploaded CSR, so an NPI there has to be typed in. Worth extending?

🤖 Generated with Claude Code

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>
…al CSRs

The SAN type dropdowns in issuance, external requests, the CSR builder and
the portal request form now read DNS, URI, Email, IP Address and NPI
instead of the enum names. Stored tokens are unchanged.

The portal's CSR parser read only DNS and IP SANs, so a subscriber had to
retype a URI, email or NPI that was already in the uploaded CSR. It now
reads every SAN form the portal can request, including an NPI otherName
(2.16.840.1.113883.4.6, UTF8String), and keeps URI values verbatim.
Other otherNames are skipped. The CA still validates every value at
issuance.

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

Copy link
Copy Markdown
Owner Author

Decisions on the open questions:

  1. Labels: the SAN type dropdowns now show friendly names (DNS, URI, Email, IP Address, NPI) in issuance, external requests, the CSR builder and the portal. Stored tokens are unchanged. SanTypeDisplayName(IpAddress) is now "IP Address", which also appears in the missing-SAN-type message.
  2. Required NPI: no separate flag. NPI behaves like the other SAN-type checkboxes; the DirectTrust profiles, including the TEFCA RCE (UDAP) profile, make the NPI otherName optional.
  3. Portal CSR upload: done in this PR. CsrParser now reads URI, email, IP, DNS and NPI otherName SANs from an uploaded CSR, keeps URI values verbatim, and skips other otherNames. The CA still validates every value at issuance.

New tests: PortalCsrParserTests (all five SAN forms read back, URI kept verbatim, non-NPI otherName skipped, labels). Sigyll.Signing.Tests: 578 passed, 17 skipped.

@JoeShook
JoeShook marked this pull request as ready for review November 22, 2026 16:11
@JoeShook
JoeShook merged commit 564a238 into main Nov 22, 2026
7 checks passed
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.

NPI otherName SAN entries

1 participant