Skip to content

certificatePolicies extension on certificate profiles - #76

Merged
JoeShook merged 1 commit into
mainfrom
feature/63-certificate-policies
Nov 22, 2026
Merged

JoeShook merged 1 commit into
mainfrom
feature/63-certificate-policies

Conversation

@JoeShook

@JoeShook JoeShook commented Nov 21, 2026 •

Copy link
Copy Markdown
Owner

Closes #63

What changed

  • Profile field: CertificateProfile.CertificatePolicyOids holds semicolon-delimited policy OIDs. It uses the same storage convention as ExtendedKeyUsageOids. If the field is null or empty, the extension is left out, so existing profiles issue the same certificates as before.
  • Issuance: every issuance path (local, CSR, remote/Vault, hybrid) writes a non-critical certificatePolicies extension (2.5.29.32, RFC 5280 §4.2.1.4) from the profile. Only the policy OIDs are written, with no qualifiers.
  • CertificatePolicyExtension (new, Sigyll.Common/Services): a small static API meant to be reused by the preset work in TEFCA FHIR certificate presets (intermediate, client, server; production and validation) #62:
    • Parse / Normalize / FindInvalid / IsValidOid: policy text accepts ;, ,, spaces or newlines as separators, and is stored joined with ;.
    • Build(IEnumerable<string>) / Build(string?) builds the extension (optional critical).
    • Read(X509Certificate2) / Decode(X509Extension) / Describe(X509Extension) read it back, including CPS URI and user-notice qualifiers.
  • Profile editor: a "Certificate Policies" text field with inline OID validation. Save stays disabled while an entry is invalid. Clone copies the policies. CertificateProfileService.SaveAsync normalizes the list and throws ArgumentException for entries that are not OIDs.
  • Certificate viewer (ExtensionTable): shows the decoded policy OIDs and their qualifiers, so the output is the same on every OS. X509Extension.Format output depends on the platform.
  • Renewal / re-key: the predecessor's policies are carried over. A profile may add policies but may not drop any:
    • RenewalIdentity.IsCompatibleProfile filters out profiles that would drop one.
    • The issuance service refuses a renewal whose profile drops one. The error names the missing OIDs.
    • Re-sign already copies every extension, so it keeps the policies too.
    • New helper: RenewalIdentity.FindDroppedPolicies.
  • Issuance check: issuance is refused with a clear error if the stored profile has an invalid policy entry.
  • Flyway: V11__certificate_policies.sql adds CertificateProfiles.CertificatePolicyOids CHARACTER VARYING(2000). It passes tools/sql-lint/check_sql.py.

Migration number: other PRs that add Flyway migrations are open in parallel (#64, #66). V11 was the next free number on main when this branch was cut. Whichever of these PRs merges second will need its V file renumbered at merge.

How it was tested

  • dotnet build Sigyll.slnx: succeeded.
  • dotnet test _tests/Sigyll.Signing.Tests: 577 passed, 17 skipped (the existing PKCS Bump the microsoft group with 18 updates #11/SoftHSM skips), 0 failed.
  • New tests:
    • CertificatePolicyExtensionTests: OID validation, parsing and normalization; the DER output is read back by BouncyCastle; qualifier decoding; hex fallback; the profile service normalizes and refuses invalid entries.
    • RenewalIdentityTests: the policies appear in the issued certificate (non-critical) and are kept on renewal; a renewal whose profile drops a policy is refused; issuance with an invalid policy is refused; the compatible-profile rules (adding a policy is allowed, dropping one is not).
  • python tools/sql-lint/check_sql.py: 16 files, 0 problems.
  • The Flyway migration and the editor UI have not been tried against a running AppHost.

Open questions

  1. Criticality: the extension is always non-critical, which is what most trust frameworks expect. Should profiles get an "is critical" toggle, like EKU has?
  2. Qualifiers: CPS URI and user-notice qualifiers are decoded for display but cannot be configured on a profile. Should they be added later (for example, together with TEFCA FHIR certificate presets (intermediate, client, server; production and validation) #62)?
  3. Renewal strictness: dropping a policy on renewal is refused on the server, not only filtered in the UI. Before this change, a renewal of a certificate with policies (for example, an imported one) through a profile without them would have gone through. That now fails with an error naming the missing OIDs.
  4. Catalog API: CatalogProfile (portal) does not expose the policies yet. Should it?

🤖 Generated with Claude Code

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>
@JoeShook

Copy link
Copy Markdown
Owner Author

Decisions on the open questions:

  1. Criticality: stays non-critical, no toggle. Revisit if a trust community asks for a critical extension.
  2. Qualifiers: configuring CPS URI and user-notice qualifiers on a profile moves into the TEFCA presets work (TEFCA FHIR certificate profile presets #79).
  3. Renewal strictness: keep the server-side refusal when a renewal profile would drop a policy OID.
  4. Catalog API: follow-up in Portal catalog: show a profile's certificate policy OIDs #89.

No code changes needed here.

@JoeShook
JoeShook marked this pull request as ready for review November 22, 2026 15:43
@JoeShook
JoeShook merged commit 39efa0c into main Nov 22, 2026
8 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.

certificatePolicies extension support on certificate profiles

1 participant