Repository navigation
Configure HTTPS certificates for project resources - #18481
Conversation
Add default project resource HTTPS certificate configuration that maps Aspire certificate data to Kestrel's default certificate environment variables. Co-authored-by: Copilot <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 18481Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 18481" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR enables ASP.NET project resources to consume Aspire's centralized HTTPS certificate configuration without each project providing its own Kestrel certificate mapping. In WithProjectDefaults, a new WithHttpsCertificateConfiguration callback maps the generated PFX path (and optional password) to Kestrel's default certificate environment variables for TLS-enabled endpoints, and clears any stale Kestrel__Certificates__Default__Password when no password is available so Kestrel doesn't try to load the generated PFX with the wrong password. This builds on the existing experimental certificate APIs (WithHttpsCertificate, HttpsCertificateConfigurationCallbackAnnotationContext) and the execution-configuration gatherer pipeline.
Changes:
- Add a project-default HTTPS certificate callback that sets
Kestrel__Certificates__Default__Path(to the PFX) and conditionally sets/removesKestrel__Certificates__Default__Passwordfor TLS-enabled endpoints. - Introduce two private constants for the Kestrel certificate environment variable names.
- Add three unit tests covering TLS-endpoint configuration with a password, stale-password removal, and the no-TLS-endpoint case.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Aspire.Hosting/ProjectResourceBuilderExtensions.cs | Adds the HTTPS certificate configuration callback to project defaults plus the two Kestrel env-var name constants; suppresses the experimental ASPIRECERTIFICATES001 diagnostic. |
| tests/Aspire.Hosting.Tests/ProjectResourceBuilderExtensionTests.cs | Adds tests for the TLS-endpoint certificate mapping, stale-password removal, and the no-TLS case, with helpers to build a test certificate and configuration context. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
PR Testing ReportPR Information
Artifact Version Verification
Changes AnalyzedFiles Changed
Change Categories
Test Scenarios ExecutedScenario 1: PR CLI artifact verificationObjective: Verify dogfood testing used the PR artifact for the latest commit. Steps:
Evidence:
Observations:
Scenario 2: Project resource HTTPS certificate happy pathObjective: Verify a project resource with a TLS endpoint and custom HTTPS certificate receives Kestrel default certificate environment variables from the PR packages. Steps:
Evidence:
Observations:
Scenario 3: No-TLS negative caseObjective: Verify a project resource with certificate configuration but no TLS-enabled endpoint does not receive Kestrel default certificate environment variables. Steps:
Evidence:
Expected Unhappy-Path Outcome: Certificate configuration without a TLS-enabled endpoint should be safe and should not emit Kestrel certificate environment variables. Observations:
Scenario 4: Focused unit regressionObjective: Verify the PR's focused implementation-level tests pass in the current checkout, including stale password removal. Steps:
Evidence:
Observations:
Notes
Summary
Overall Result✅ PR VERIFIED Recommendations
|
Co-authored-by: Copilot <[email protected]>
Tests selector (audit mode)The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement. 52 / 98 test projects · 5 jobs, from 40 changed files. Selected test projects (52 / 98)
Selected jobs (5)
How these were chosen — grouped by what changed
🔧 show 30
🔧 🔧 🔧 🔧 📦 affected project 📦 affected project 🔧 🔧 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 🧪 Job reasons
Selection computed for commit |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Description
ASP.NET project resources can now use Aspire HTTPS certificate configuration without each project having to provide its own Kestrel mapping. When a project has a TLS-enabled endpoint and an HTTPS certificate is available, the project defaults map the generated PFX path and optional password to Kestrel's default certificate environment variables.
If no certificate password is present, the default project setup removes any stale
Kestrel__Certificates__Default__Passwordvalue that may have been configured earlier, so Kestrel does not try to load the generated PFX with the wrong password.User-facing usage
Existing certificate APIs can be used with project resources:
The project defaults apply the corresponding Kestrel certificate environment variables for TLS endpoints.
Validation:
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?