Skip to content

Advise aspire certs trust in polyglot HTTPS dev-cert errors#17348

Merged
sebastienros merged 3 commits into
mainfrom
mitchdenny/ts-apphost-aspire-certs-trust-guidance
May 21, 2026
Merged

Advise aspire certs trust in polyglot HTTPS dev-cert errors#17348
sebastienros merged 3 commits into
mainfrom
mitchdenny/ts-apphost-aspire-certs-trust-guidance

Conversation

@mitchdenny
Copy link
Copy Markdown
Member

Description

When a TypeScript (or other polyglot) app host fails to start because the ASP.NET Core HTTPS developer certificate is missing or untrusted, Kestrel surfaces a message that tells users to run dotnet dev-certs https and dotnet dev-certs https --trust, and points them at https://go.microsoft.com/fwlink/?linkid=848054. That advice assumes the .NET SDK is on PATH, which is not guaranteed for Node.js / Python / etc. app host users, and the fwlink is not the right destination for Aspire docs.

This change rewrites the message on its way through the polyglot capability layer so polyglot users see Aspire CLI guidance instead:

Unable to configure HTTPS endpoint. ... To generate and trust a developer certificate run aspire certs trust. For more information on configuring HTTPS see https://aspire.dev/docs/.

Approach

PolyglotCapabilityErrorFormatter.ScrubMessage is the single chokepoint that all exception messages flow through on their way to polyglot (non-.NET) hosts. Native .NET app hosts never go through this code path, so their guidance is unchanged.

ASP.NET Core's Kestrel throws a plain InvalidOperationException from TlsConfigurationLoader.UseHttpsWithDefaults with no HResult and no specific exception type, so the message text is the only signal available. The fwlink ID 848054 has been the unique sentinel for this exact error since .NET Core 2.1 and does not appear in any other Kestrel error, so it is used purely as a detection sentinel; when it appears, the entire message is replaced with a single polyglot-friendly constant owned by us. This avoids any dependency on the exact wording of the surrounding sentences. If a future framework release ever removes the fwlink, the rewrite degrades gracefully: detection misses and the original message propagates unchanged.

Verified with the existing PolyglotFormatter_* tests plus a new regression test that pipes the exact Kestrel message through CreateInternalError and asserts the rewrite.

Fixes: #17273

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

Mitch Denny and others added 3 commits May 21, 2026 15:24
Kestrel's HTTPS dev-cert guidance points users at 'dotnet dev-certs https'
and a go.microsoft.com fwlink. For TypeScript/Node.js (and other polyglot)
app hosts that flow through PolyglotCapabilityErrorFormatter, this is poor
advice because the .NET SDK may not be on PATH. Rewrite the guidance to
point at 'aspire certs trust' (which both creates and trusts the cert in
one step) and at https://aspire.dev/docs/ so polyglot users get advice
that works in their environment.

Native .NET app hosts do not flow through this formatter and are
unaffected.

Fixes #17273

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per review feedback: ASP.NET Core's Kestrel throws a plain
InvalidOperationException from TlsConfigurationLoader.UseHttpsWithDefaults
with no HResult and no specific exception type, so there is no error code
to key off. Confirmed by inspecting upstream sources:

  - CoreStrings.resx -> NoCertSpecifiedNoDevelopmentCertificateFound
  - TlsConfigurationLoader.cs -> throw new InvalidOperationException(...)

The fwlink identifier 848054 has been the unique sentinel for this exact
error since .NET Core 2.1, and it does not appear in any other Kestrel
error. Switch to a single source-generated regex anchored on the fwlink
that tolerates whitespace/line-ending variation. If a future framework
release reworks the message such that the fwlink is gone, the rewrite
degrades gracefully: the regex misses, the original text propagates, and
no incorrect substitution occurs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per review feedback: simplify the rewrite by using the fwlink ID 848054
purely as a detection sentinel and replacing the whole Kestrel message
with a polyglot-friendly equivalent. This removes the dependency on the
exact wording of every sentence in the Kestrel string -- only the fwlink
needs to match for detection to fire, and the replacement is fully
controlled by us instead of stitched together from the original message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mitchdenny mitchdenny requested a review from sebastienros as a code owner May 21, 2026 06:01
Copilot AI review requested due to automatic review settings May 21, 2026 06:01
@github-actions
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/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 17348

Or

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the polyglot capability error formatting so that when ASP.NET Core Kestrel reports a missing/untrusted HTTPS development certificate (the message containing fwlink 848054), polyglot app hosts (TypeScript/Node.js, Python, etc.) receive Aspire CLI guidance instead of dotnet dev-certs guidance.

Changes:

  • Add a rewrite step in PolyglotCapabilityErrorFormatter.ScrubMessage that detects the Kestrel HTTPS dev-cert error via the fwlink sentinel and replaces the entire message with an Aspire-specific, polyglot-friendly message (aspire certs trust + https://aspire.dev/docs/).
  • Add a regression test ensuring Kestrel’s original dotnet dev-certs and fwlink guidance is removed and the Aspire guidance is present.
Show a summary per file
File Description
src/Aspire.Hosting.RemoteHost/Ats/PolyglotCapabilityInvocationException.cs Rewrites the Kestrel dev-cert guidance for polyglot callers by detecting the fwlink sentinel and substituting Aspire CLI guidance.
tests/Aspire.Hosting.RemoteHost.Tests/CapabilityDispatcherTests.cs Adds a regression test to validate the message rewrite behavior through CreateInternalError/ToCapabilityException().

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@github-actions
Copy link
Copy Markdown
Contributor

CLI E2E Tests unknown — 95 passed, 0 failed, 5 unknown (commit 3d1962d)

View all recordings
Status Test Recording
AddPackageInteractiveWhileAppHostRunningDetached ▶️ View recording
AddPackageWhileAppHostRunningDetached ▶️ View recording
AgentCommands_AllHelpOutputs_AreCorrect ▶️ View recording
AgentInitCommand_DefaultSelection_InstallsDefaultSkills ▶️ View recording
AgentInitCommand_MigratesDeprecatedConfig ▶️ View recording
AgentMcpListStructuredLogsFromStarterAppCore ▶️ View recording
AllPublishMethodsBuildDockerImages ▶️ View recording
AspireAddPackageVersionToDirectoryPackagesProps ▶️ View recording
AspireInitSingleFileAppHostRunsViaDotnetRunAppHost ▶️ View recording
AspireInitWithExistingAppHostDirRecreatesMissingNuGetConfigAndPreservesFiles ▶️ View recording
AspireInitWithSolutionFileGeneratesAppHostThatBuildsAgainstChannelHive ▶️ View recording
AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View recording
AspireUpdateRemovesOrphanAppHostPackageVersionWhenSdkAlreadyCurrent ▶️ View recording
Banner_DisplayedOnFirstRun ▶️ View recording
Banner_DisplayedWithExplicitFlag ▶️ View recording
Banner_NotDisplayedWithNoLogoFlag ▶️ View recording
CertificatesClean_RemovesCertificates ▶️ View recording
CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View recording
CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View recording
ConfigSetGet_CreatesNestedJsonFormat ▶️ View recording
CreateAndRunAspireStarterProject ▶️ View recording
CreateAndRunAspireStarterProjectWithBundle ▶️ View recording
CreateAndRunEmptyAppHostProject ▶️ View recording
CreateAndRunJavaEmptyAppHostProject ▶️ View recording
CreateAndRunJsReactProject ▶️ View recording
CreateAndRunPythonReactProject ▶️ View recording
CreateAndRunTypeScriptEmptyAppHostProject ▶️ View recording
CreateAndRunTypeScriptStarterProject ▶️ View recording
CreateJavaAppHostWithViteApp ▶️ View recording
CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View recording
DashboardRunWithAgentMcpCore ▶️ View recording
DashboardRunWithOtelTracesReturnsNoTracesCore ▶️ View recording
DeployK8sBasicApiService ▶️ View recording
DeployK8sWithExternalHelmChart ▶️ View recording
DeployK8sWithGarnet ▶️ View recording
DeployK8sWithMongoDB ▶️ View recording
DeployK8sWithMySql ▶️ View recording
DeployK8sWithPostgres ▶️ View recording
DeployK8sWithRabbitMQ ▶️ View recording
DeployK8sWithRedis ▶️ View recording
DeployK8sWithSqlServer ▶️ View recording
DeployK8sWithValkey ▶️ View recording
DeployTypeScriptAppToKubernetes ▶️ View recording
DescribeCommandResolvesReplicaNames ▶️ View recording
DescribeCommandShowsRunningResources ▶️ View recording
DetachFormatJsonProducesValidJson ▶️ View recording
DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View recording
DoListStepsShowsPipelineSteps ▶️ View recording
DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View recording
DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View recording
DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View recording
DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View recording
DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View recording
GeneratedAspireDevScript_StartsWatchMode_WithConfiguredToolchain ▶️ View recording
GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View recording
GlobalMigration_HandlesMalformedLegacyJson ▶️ View recording
GlobalMigration_PreservesAllValueTypes ▶️ View recording
GlobalMigration_SkipsWhenNewConfigExists ▶️ View recording
GlobalSettings_MigratedFromLegacyFormat ▶️ View recording
InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View recording
InteractiveCSharpInitCreatesExpectedFiles ▶️ View recording
InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View recording
JavaScriptHostingApisRunFromTypeScriptAppHost ▶️ View recording
LatestCliCanStartStableChannelAppHost ▶️ View recording
LatestCliCanStartStableChannelTypeScriptAppHost ▶️ View recording
LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View recording
LogLevelTrace_ProducesTraceEntriesInCliLogFile ▶️ View recording
LogsCommandShowsResourceLogs ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterApp ▶️ View recording
OtelLogsReturnsStructuredLogsFromStarterAppIsolated ▶️ View recording
PsCommandListsRunningAppHost ▶️ View recording
PsFormatJsonOutputsOnlyJsonToStdout ▶️ View recording
PublishJavaScriptPatternsGeneratesExpectedDockerComposeArtifacts ▶️ View recording
PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View recording
PublishWithDockerComposeServiceCallbackSucceeds ▶️ View recording
PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View recording
ResourceCommand_FailedExecution_DisplaysAppHostLogPathAndLogContainsEntries ▶️ View recording
ResourceCommand_FailsWhenInteractionServiceIsRequired ▶️ View recording
ResourceCommand_SetAndDeleteParameterUpdatesDescribeOutput ▶️ View recording
RestoreGeneratesSdkFiles ▶️ View recording
RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View recording
RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View recording
RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View recording
RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View recording
RunPublishFailureScenarioAsync ▶️ View recording
RunReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
RunReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
SecretCrudOnDotNetAppHost ▶️ View recording
SecretCrudOnTypeScriptAppHost ▶️ View recording
StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View recording
StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View recording
StartReportsSyntaxErrorsForDotNetAppHost ▶️ View recording
StartReportsSyntaxErrorsForTypeScriptAppHost ▶️ View recording
StopAllAppHostsFromAppHostDirectory ▶️ View recording
StopJavaPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopNonInteractiveSingleAppHost ▶️ View recording
StopTypeScriptPolyglotAppHostUsingApphostDirectory ▶️ View recording
StopWithNoRunningAppHostExitsSuccessfully ▶️ View recording
UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View recording
UpdateProjectChannelToStable_TypeScript_PicksUpStablePackages ▶️ View recording

📹 Recordings uploaded automatically from CI run #26208483721

@sebastienros sebastienros merged commit 95d2b5b into main May 21, 2026
605 of 609 checks passed
@sebastienros sebastienros deleted the mitchdenny/ts-apphost-aspire-certs-trust-guidance branch May 21, 2026 15:18
@microsoft-github-policy-service microsoft-github-policy-service Bot added this to the 13.4 milestone May 21, 2026
aspire-repo-bot Bot added a commit to microsoft/aspire.dev that referenced this pull request May 21, 2026
TypeScript (and other polyglot) app host users may not have the .NET SDK
on their PATH, so `dotnet dev-certs https --trust` guidance doesn't apply.
Aspire now surfaces `aspire certs trust` in HTTPS error messages for
polyglot hosts (microsoft/aspire#17348).

Add an 'HTTPS development certificates' section to the TypeScript AppHost
project structure page explaining how to resolve the error with
`aspire certs trust`, with a tip for clean+trust recovery and a cross-
reference to the full certificate-configuration docs.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot
Copy link
Copy Markdown
Contributor

Pull request created: #1032

Generated by PR Documentation Check

@aspire-repo-bot
Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1032 targeting release/13.4.

Drafted a docs PR adding an "HTTPS development certificates" section to typescript-apphost.mdx for TypeScript AppHost users who may not have dotnet on their PATH.\n\nTriggered signal: pr_body_has_cli_flag_mention — the source PR body mentions dotnet dev-certs https --trust (the old guidance being replaced by aspire certs trust).\n\nThe new section shows the Kestrel error message users will see, the aspire certs trust fix command, a recovery tip (aspire certs clean + aspire certs trust), and a cross-reference to certificate-configuration docs. See also links updated with aspire certs trust and Certificate configuration.

Note

This draft PR needs human review before merging.

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.

Aspire TS App Host should advise aspire certs trust rather than dotnet dev-certs trust

3 participants