aspire: [WebToolsE2E][Aspire] With the dev cert not trusted, when running Aspire app with https, the dashboard page fails to load with the browser dev tools showing: Error starting gRPC call. HttpRequestException: The SSL connection could not be established, see inner exception. AuthenticationException

REGRESSION INFO: https is a new feature on Aspire 8.0 P5

INSTALL STEPS

  1. Clean machine: Win11 x64 23h2 ENU
  2. Install the SDK 8.0.300-preview.24164.23
  3. Install Aspire.ProjectTemplates.8.0.0-preview.5.24164.9
  4. Apply nuget dotnet8 feed

REPRO STEPS

  1. Open cmd, run following code to create an aspire / aspire-starter app and run with https
    dotnet new aspire-starter -o AspireSta
    cd AspireSta/AspireSta.AppHost
    dotnet run -lp https
    
  2. Go to https://localhost:xxxx

Note

  1. Running with http works fine.

Workaround

  1. Run dotnet dev-certs https --trust (Windows and macOS only ) to trust the certificate, then run it again with https, it works fine.
  2. But this workaround only supports windows/mac, not linux.

ACTUAL The exception only shows up in the browser F12 tool and not in the console output.

image

image Error: Grpc.Core.RpcException: Status(StatusCode=“Internal”, Detail=“Error starting gRPC call. HttpRequestException: The SSL connection could not be established, see inner exception. AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot”, DebugException=“System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.”) —> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. —> System.Security.Authentication.AuthenticationException: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot at System.Net.Security.SslStream.CompleteHandshake(SslAuthenticationOptions sslAuthenticationOptions) at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken) at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) — End of inner exception stack trace — at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp2ConnectionAsync(QueueItem queueItem) at System.Threading.Tasks.TaskCompletionSourceWithCancellation1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at Grpc.Net.Client.Balancer.Internal.BalancerHttpHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) at Grpc.Net.Client.Internal.GrpcCall2.RunCall(HttpRequestMessage request, Nullable1 timeout) --- End of inner exception stack trace --- at Grpc.Net.Client.Internal.Retry.RetryCall2.StartRetry(Action1 startCallFunc) at Grpc.Net.Client.Internal.Retry.RetryCallBase2.GetResponseCoreAsync() at Aspire.Dashboard.Model.DashboardClient.<>c__DisplayClass25_0.<<EnsureInitialized>g__ConnectAsync|2>d.MoveNext() in //src/Aspire.Dashboard/Model/DashboardClient.cs:line 164 — End of stack trace from previous location — at Aspire.Dashboard.Components.ApplicationName.OnInitializedAsync() in //src/Aspire.Dashboard/Components/Controls/ApplicationName.razor.cs:line 32 at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

EXPECTED image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 28 (24 by maintainers)

Most upvoted comments

Long, long ago I was prototyping some code to create and install a developer certificate on Linux. I just did some work to package it as a global tool and support Debian based distro (except for a Ubuntu browser issue). You can find it here: https://github.com/tmds/linux-dev-certs.

If you run into this issue on a Linux system (where dev-certs https --trust is not supported), you can use http instead of https:

export ASPIRE_ALLOW_UNSECURED_TRANSPORT=true
dotnet run --launch-profile http

The security impact of this is limited because the services bind to localhost, and only someone with sufficient privileges on the system to capture interface packets will now be able to see unencrypted packages instead of encrypted ones.

Updated title so that this issue is easier to find. With https profile now being the default for Aspire Apps in Aspire 8.0 Preview 5, we now get this warning when we do dotnet run. This is expected.

Workaround: As described in the warning, you can trust the dev certificate by running the command dotnet dev-certs https --trust to fix this problem.

image

Thanks @amcasey! I opened https://github.com/dotnet/aspire/issues/3262 to track doing this work.

We suppressed that because we wanted to tightly control what was being output to the console. For example if you raise it to warning you get this in the output:

image