Skip to content

[docs] Document explicit Kestrel certificate configuration preservation - #1669

Merged
David Pine (IEvangelist) merged 1 commit into
release/13.6from
docs/pr-20133-35003411013-1-d5b580c986c54cf9
Sep 24, 2026
Merged

David Pine (IEvangelist) merged 1 commit into
release/13.6from
docs/pr-20133-35003411013-1-d5b580c986c54cf9

Conversation

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Documents changes from microsoft/aspire#20133

@karolz-ms

Targeting release/13.6 based on the source PR milestone 13.6.

Why this is needed

microsoft/aspire#20133 fixes a bug where WithProjectDefaults() would overwrite an explicitly configured Kestrel certificate for .NET project resources with TLS-enabled endpoints. When a resource already used an explicit PEM certificate/key pair (or a certificate store Subject) via WithHttpsCertificateConfiguration, Aspire's default PFX mapping replaced Kestrel__Certificates__Default__Path while leaving KeyPath in place, producing a mixed PFX/PEM configuration that Kestrel rejected with "The provided key file is missing or invalid."

The fix preserves the entire existing certificate configuration (untouched) whenever Kestrel__Certificates__Default__Path, Kestrel__Certificates__Default__KeyPath, or Kestrel__Certificates__Default__Subject is already present (matched case-insensitively), and only falls back to the default PFX mapping when none of those keys exist.

What changed

Added a note to src/frontend/src/content/docs/app-host/certificate-configuration.mdx, in the "Customize certificate configuration" section, explaining:

  • WithProjectDefaults maps the available HTTPS certificate to Kestrel's default PFX environment variables for .NET project resources with TLS-enabled endpoints.
  • This mapping is skipped, and the existing certificate configuration (including password) is preserved, if an earlier callback already set Kestrel__Certificates__Default__Path, Kestrel__Certificates__Default__KeyPath, or Kestrel__Certificates__Default__Subject.
  • Why this matters: it prevents Aspire from mixing an explicit PEM cert/key pair with a replaced PFX path, which Kestrel can't load.

Files modified

  • src/frontend/src/content/docs/app-host/certificate-configuration.mdx (updated existing page — added an <Aside type="note"> in the "Customize certificate configuration" section)

Generated by PR Documentation Check for #20133 · auto · 85.5 AIC · ⌖ 9.4 AIC · ⊞ 18.5K · ◷

Adds a note to the certificate-configuration doc explaining that
WithProjectDefaults preserves an existing explicit Kestrel certificate
selection (Path, KeyPath, or Subject) instead of overwriting it with
the default PFX mapping, per microsoft/aspire#20133.

Co-authored-by: Copilot <[email protected]>
@aspire-repo-bot aspire-repo-bot Bot added the docs-from-code Copilot initiated issue from dotnet/aspire repo label Sep 15, 2026
@aspire-repo-bot

Copy link
Copy Markdown
Contributor Author

Frontend HTML artifact ready

The latest frontend build uploaded the frontend-dist artifact for PR #1669. Use the VS Code button below to open this PR with GitHub Artifacts Explorer and browse the built HTML locally.

VS Code: Open PR #1669 artifacts

This comment updates automatically when a new frontend build artifact is uploaded.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

Final human review is recommended.

Review effort: Lite
Findings: None

What changed in this PR

This pull request documents preservation of explicit Kestrel certificate configuration for .NET project resources.

Changes:

  • Explains default PFX mapping by WithProjectDefaults.
  • Documents preservation of existing PEM, certificate-store, and password settings.
  • Explains the PEM/PFX mixing failure scenario.
File Description
src/​frontend/​src/​content/​docs/​app-host/​certificate-configuration.mdx Adds Kestrel certificate-preservation guidance.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@IEvangelist David Pine (IEvangelist) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated docs-accuracy review

Phase A source of truth: microsoft/aspire @ release/13.6 (SHA 63b5556c7f4de9b259d6ba71a312f597a72bf307), source PR microsoft/aspire#20133 (commit e01d15dae2, "Preserve explicit Kestrel certificate configuration").
Claims extracted: 4 non-narrative → 4 verified, 0 verified-with-nuance, 0 unverifiable, 0 contradicted.
Phase B (doc-tester): exercised /app-host/certificate-configuration/ — 0 critical, 0 warnings.

Verdict: APPROVE — the new Aside describes the preservation behavior exactly as implemented.


Phase A — Claim verification

✅ Verified claims (4) — evidence
  • C1 — WithProjectDefaults maps the available HTTPS certificate to Kestrel's default PFX env vars (Kestrel__Certificates__Default__Path and …__Password) for TLS-enabled project endpoints (certificate-configuration.mdx:354-357): verified. ProjectResourceBuilderExtensions.cs XML doc: "For TLS-enabled endpoints, an available HTTPS certificate is mapped to Kestrel's default certificate"; implementation sets ctx.EnvironmentVariables[KnownAspNetCoreConfigNames.KestrelCertificatesDefaultPath] = ctx.PfxPath and [KestrelCertificatesDefaultPassword] = ctx.Password.
  • C2 — If an earlier WithHttpsCertificateConfiguration callback already set …Default__Path, …__KeyPath, or …__Subject (case-insensitive), the default PFX mapping is skipped entirely and the existing configuration — including any password — is left untouched (certificate-configuration.mdx:357-362): verified. Implementation short-circuits: if (ctx.EnvironmentVariables.Keys.Any(name => string.Equals(name, KestrelCertificatesDefaultPath, StringComparisons.EnvironmentVariableName) || …KeyPath || …Subject)) { return Task.CompletedTask; }. XML doc: "The presence of any of them preserves the existing certificate configuration, including its password. Settings supplied by earlier HTTPS certificate callbacks participate in this check."
  • C3 — Config-key names Kestrel__Certificates__Default__Path / …__Password / …__KeyPath / …__Subject (Aside): verified. KnownAspNetCoreConfigNames constants match all four names verbatim.
  • C4 — Skipping prevents Aspire from mixing an explicit PEM certificate/key pair with a replaced PFX path, which Kestrel can't load (certificate-configuration.mdx:362-364): verified. Implementation comment: "Preserve an explicit certificate selection as a group. Replacing a PEM Path with a PFX path while retaining KeyPath makes Kestrel load incompatible files. microsoft/aspire#20019".

Case-insensitivity note: StringComparisons.EnvironmentVariableName => StringComparison.OrdinalIgnoreCase — confirms the "matched case-insensitively" wording.


Phase B — Doc-tester results

Scope: the single doc route touched by this PR. Tested against the live production site (release/13.6 is not yet published, no per-PR preview exists, and frontend deps are not installed in this hourly job).

Critical issues: none.
Warnings: none.

Passed checks:

  • /app-host/certificate-configuration/ loads (200; title "Certificate configuration").
  • Insertion point is clean: the HttpsCertificateConfigurationCallbackAnnotationContext bullet list (ExecutionContext, Resource) is immediately followed by the ## Certificate trust configuration heading, so the new note Aside lands between them.
  • The section's heading anchors resolve in the on-page table of contents.

Knowledge gaps / limitations:

  • PR content isn't deployed, so the new Aside couldn't be rendered as it will appear.
  • The Kestrel default-certificate env-var mapping / skip behavior can't be exercised from the docs site. Phase A confirmed it from source (ProjectResourceBuilderExtensions.cs skip logic, KnownAspNetCoreConfigNames, OrdinalIgnoreCase).

Automated review. Phase A reads microsoft/aspire source; Phase B validates the rendered docs site as a blind user; only PR-changed content and its routes were in scope.

@IEvangelist
David Pine (IEvangelist) merged commit f3d0e9e into release/13.6 Sep 24, 2026
11 of 12 checks passed
@IEvangelist
David Pine (IEvangelist) deleted the docs/pr-20133-35003411013-1-d5b580c986c54cf9 branch September 24, 2026 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs-from-code Copilot initiated issue from dotnet/aspire repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants