Skip to content

Add logging if we detect the app host is running with an untrusted dev cert - #13943

Closed
David Negstad (danegsta) wants to merge 19 commits into
mainfrom
danegsta/trust
Closed

Add logging if we detect the app host is running with an untrusted dev cert#13943
David Negstad (danegsta) wants to merge 19 commits into
mainfrom
danegsta/trust

Conversation

@danegsta

Copy link
Copy Markdown
Member

Description

It's possible, particularly after .NET SDK updates, to end up in a situation where there's a newer dev cert added to the CurrentUser/My cert store (which is the source of dev certs for TLS termination), but not to the CurrentUser/Root cert store which is where trusted certificates are pulled from. This can lead to a situation where services try to terminate HTTPS endpoints with an updated dev cert, but nothing actually trusts the new certificate. Diagnosing the issue is confusing and can require checking the logs for individual services.

This adds an explicit error level log if automatic dev cert trust is enabled and the latest certificate isn't in the trusted root store.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No
  • Does the change require an update in our Aspire docs?

Copilot AI review requested due to automatic review settings January 15, 2026 21:44
@github-actions

github-actions Bot commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13943

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13943"

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 reviewed 1 out of 1 changed files in this pull request and generated 4 comments.

Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated
Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated
Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated
Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated

Copilot AI commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

David Negstad (@danegsta) I've opened a new pull request, #13946, to work on those changes. Once the pull request is ready, I'll request review from you.

@davidfowl

Copy link
Copy Markdown
Contributor

Logging isn't good enough, lets turn this into a notification.

@danegsta

Copy link
Copy Markdown
Member Author

Logging isn't good enough, lets turn this into a notification.

Added both a notification and explicitly controlling the dev cert the dashboard uses.

@mitchdenny

Copy link
Copy Markdown
Member

/ba-g transient template failures.

@mitchdenny Mitch Denny (mitchdenny) 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.

Looks good.

Comment thread src/Aspire.Hosting/Dashboard/DashboardEventHandlers.cs
Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated
Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated
Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated
Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated
Comment thread src/Aspire.Hosting/DeveloperCertificateService.cs Outdated
@github-actions

github-actions Bot commented Jan 24, 2026

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings

The following terminal recordings are available for commit 157a72c:

Test Recording
CreateAndDeployToDockerCompose ▶️ View Recording
CreateAndDeployToDockerComposeInteractive ▶️ View Recording
CreateAndRunAspireStarterProject ▶️ View Recording
CreateAndRunJsReactProject ▶️ View Recording
CreateAndRunPythonReactProject ▶️ View Recording
CreateEmptyAppHostProject ▶️ View Recording
CreateStartAndStopAspireProject ▶️ View Recording
CreateTypeScriptAppHostWithViteApp ▶️ View Recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
PsCommandListsRunningAppHost ▶️ View Recording

📹 Recordings uploaded automatically from CI run #21379107285

logger.LogWarning("{Message}", message);

// Send notification to the dashboard
_ = interactionService.PromptNotificationAsync(

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.

Why

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I moved where the check happens to DcpHost alongside the container runtime check.

Copilot AI commented Jan 24, 2026

Copy link
Copy Markdown
Contributor

David Negstad (@danegsta) I've opened a new pull request, #14110, to work on those changes. Once the pull request is ready, I'll request review from you.

@davidfowl

Copy link
Copy Markdown
Contributor

Damian Edwards (@DamianEdwards) can you try this out.

@DamianEdwards

Damian Edwards (DamianEdwards) commented Feb 4, 2026

Copy link
Copy Markdown
Member

✅ PR #13943 Validation Report - VERIFIED

PR Information

  • Title: Add logging if we detect the app host is running with an untrusted dev cert
  • Head Commit: 157a72cc734739e9bd3613abb5193cb646f64545
  • Tested At: 2026-02-04

CLI Version Verification

  • Expected Commit: 157a72cc
  • Installed Version: 13.2.0-pr.13943.g157a72cc
  • Status: ✅ Verified

Test Results

Scenario Status Notes
1. Basic Aspire Project Run ✅ Passed 2 resources running correctly
2. Untrusted Cert Notification ✅ Passed Dashboard shows notification banner
3. Trusted Cert (Baseline) ✅ Passed No notification when cert is trusted

Evidence

Scenario 2 - Untrusted Certificate:

  • Console: ⚠ Developer certificates may not be fully trusted (trust exit code was: 4)
  • Log: [Warning] Aspire.Hosting.Dcp.DcpHost: The most recent ASP.NET Core Development Certificate isn't fully trusted. Run 'dotnet dev-certs https --trust'...
  • Dashboard: Notification banner visible - "Development certificate not fully trusted"
scenario2-untrusted-cert-notification

Scenario 3 - Trusted Certificate:

  • Console: No cert warnings
  • Log: No cert warnings
  • Dashboard: No notification banner
scenario3-trusted-cert-no-notification

Overall Result: ✅ PR VERIFIED

The PR correctly implements:

  1. Warning-level logging when the dev cert is untrusted
  2. Dashboard notification banner with actionable guidance (dotnet dev-certs https --trust)
  3. No false positives when the certificate is properly trusted

📋 Full session log: https://gist.github.com/DamianEdwards/9a40bff87fcf4cb6bd37321673feab10

@danegsta

Copy link
Copy Markdown
Member Author

Replaced by #14666 targeting release/13.2.

@dotnet-policy-service dotnet-policy-service Bot modified the milestones: 13.2, 13.3 Feb 25, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants