Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intermittent CryptographicException while running standalone aspire dashboard makes dashboard unusable #6961

Open
1 task done
stevesea opened this issue Dec 17, 2024 · 1 comment
Labels
area-dashboard untriaged New issue has not been triaged

Comments

@stevesea
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Running latest standalone dashboard (9.0.0) via docker run :

docker run --rm -it -p 8000:18888 -p 4317:18889 -p 4318:18890 --name aspire-dashboard -e DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS="true" mcr.microsoft.com/dotnet/aspire-dashboard

Started a spring boot Java application (spring boot 3.4.0, temurin Java 21), with the Java Otel agent 2.10.0.

The standalone dashboard (sometimes) becomes unusable, and the UI prompts to reload with an error popup:
An unhandled error has occurred. [Reload](http://localhost:8000/)

Looking at the output from the container, I see logs like:

warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
      Unhandled exception rendering component: The key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
      System.Security.Cryptography.CryptographicException: The key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
         at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData)
         at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.Unprotect[TValue](String purpose, String protectedJson)
         at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.GetAsync[TValue](String purpose, String key)
         at Aspire.Dashboard.Model.BrowserStorage.BrowserStorageBase.GetAsync[T](String key) in /_/src/Aspire.Dashboard/Model/BrowserStorage/BrowserStorageBase.cs:line 19
         at Aspire.Dashboard.Components.Pages.PageExtensions.InitializeViewModelAsync[TViewModel,TSerializableViewModel](IPageWithSessionAndUrlState`2 page) in /_/src/Aspire.Dashboard/Components/Pages/IPageWithSessionAndUrlState.cs:line 97
         at Aspire.Dashboard.Components.Pages.Metrics.OnParametersSetAsync() in /_/src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs:line 106
         at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
         at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit '_iAUph4MiFsFrX_765oiV9PkVlVfW7htVOu8qVtM8dE'.
      System.Security.Cryptography.CryptographicException: The key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
         at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData)
         at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.Unprotect[TValue](String purpose, String protectedJson)
         at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.GetAsync[TValue](String purpose, String key)
         at Aspire.Dashboard.Model.BrowserStorage.BrowserStorageBase.GetAsync[T](String key) in /_/src/Aspire.Dashboard/Model/BrowserStorage/BrowserStorageBase.cs:line 19
         at Aspire.Dashboard.Components.Pages.PageExtensions.InitializeViewModelAsync[TViewModel,TSerializableViewModel](IPageWithSessionAndUrlState`2 page) in /_/src/Aspire.Dashboard/Components/Pages/IPageWithSessionAndUrlState.cs:line 97
         at Aspire.Dashboard.Components.Pages.Metrics.OnParametersSetAsync() in /_/src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs:line 106
         at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
         at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Once I start seeing this, even restarting the container doesn't always clear it. Which feels very odd. 🤷

Maybe some state saved in the browser?

I'm writing up some internal docs, and I'm often restarting the docker container and Java app, but I tend to leave the browser tab open.

A reliable way I've found to get out of this bad state is to be very careful on the order I shutdown & startup things:

  • shut down the aspire dashboard
  • kill the java app
  • close the browser window
  • docker run the standalone aspire dashboard
  • start the java app
  • navigate in the browser to localhost:8000

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
Unhandled exception rendering component: The key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
System.Security.Cryptography.CryptographicException: The key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData)
at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.Unprotect[TValue](String purpose, String protectedJson)
at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.GetAsync[TValue](String purpose, String key)
at Aspire.Dashboard.Model.BrowserStorage.BrowserStorageBase.GetAsync[T](String key) in //src/Aspire.Dashboard/Model/BrowserStorage/BrowserStorageBase.cs:line 19
at Aspire.Dashboard.Components.Pages.PageExtensions.InitializeViewModelAsync[TViewModel,TSerializableViewModel](IPageWithSessionAndUrlState2 page) in /_/src/Aspire.Dashboard/Components/Pages/IPageWithSessionAndUrlState.cs:line 97 at Aspire.Dashboard.Components.Pages.Metrics.OnParametersSetAsync() in /_/src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs:line 106 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync() at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState) fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111] Unhandled exception in circuit '6GFznW-gBuA4a6SiGSoFPiL3bmDSoq2ngV4blvdc9v4'. System.Security.Cryptography.CryptographicException: The key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status) at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData) at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData) at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.Unprotect[TValue](String purpose, String protectedJson) at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.GetAsync[TValue](String purpose, String key) at Aspire.Dashboard.Model.BrowserStorage.BrowserStorageBase.GetAsync[T](String key) in /_/src/Aspire.Dashboard/Model/BrowserStorage/BrowserStorageBase.cs:line 19 at Aspire.Dashboard.Components.Pages.PageExtensions.InitializeViewModelAsync[TViewModel,TSerializableViewModel](IPageWithSessionAndUrlState2 page) in /
/src/Aspire.Dashboard/Components/Pages/IPageWithSessionAndUrlState.cs:line 97
at Aspire.Dashboard.Components.Pages.Metrics.OnParametersSetAsync() in /_/src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs:line 106
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

.NET Version info

No response

Anything else?

.NET Aspire version 9.0.0
Spring Boot 3.4.0
Java 21.0.1 (eclipse temurin)
OTel Java agent 2.10.0

@stevesea
Copy link
Author

stevesea commented Dec 17, 2024

oops. never looked at earlier runs in my console output to find that key ID mentioned in the exception.

Seems like it is the ephemeral key used by an earlier version of the dashboard (cntrl-C'd to kill that container).

❯ docker run --rm -it -p 8000:18888 -p 4317:18889 -p 4318:18890 --name aspire-dashboard -e DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS="true" mcr.microsoft.com/dotnet/aspire-dashboard
info: Aspire.Dashboard.DashboardWebApplication[0]
      Aspire version: 9.0.0+01ed51919f8df692ececce51048a140615dc759d
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/home/app/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} may be persisted to storage in unencrypted form.
info: Aspire.Dashboard.DashboardWebApplication[0]
      Now listening on: http://[::]:18888
info: Aspire.Dashboard.DashboardWebApplication[0]
      OTLP/gRPC listening on: http://[::]:18889
info: Aspire.Dashboard.DashboardWebApplication[0]
      OTLP/HTTP listening on: http://[::]:18890
warn: Aspire.Dashboard.DashboardWebApplication[0]
      OTLP server is unsecured. Untrusted apps can send telemetry to the dashboard. For more information, visit https://go.microsoft.com/fwlink/?linkid=2267030
^C%                                                                                                                                                                                                                                                                              
❯ docker run --rm -it -p 8000:18888 -p 4317:18889 -p 4318:18890 --name aspire-dashboard -e DOTNET_DASHBOARD_UNSECURED_ALLOW_ANONYMOUS="true" mcr.microsoft.com/dotnet/aspire-dashboard
info: Aspire.Dashboard.DashboardWebApplication[0]
      Aspire version: 9.0.0+01ed51919f8df692ececce51048a140615dc759d
warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
      Storing keys in a directory '/home/app/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed. For more information go to https://aka.ms/aspnet/dataprotectionwarning
warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
      No XML encryptor configured. Key {39047ed0-9972-469b-9338-0500829538b1} may be persisted to storage in unencrypted form.
info: Aspire.Dashboard.DashboardWebApplication[0]
      Now listening on: http://[::]:18888
info: Aspire.Dashboard.DashboardWebApplication[0]
      OTLP/gRPC listening on: http://[::]:18889
info: Aspire.Dashboard.DashboardWebApplication[0]
      OTLP/HTTP listening on: http://[::]:18890
warn: Aspire.Dashboard.DashboardWebApplication[0]
      OTLP server is unsecured. Untrusted apps can send telemetry to the dashboard. For more information, visit https://go.microsoft.com/fwlink/?linkid=2267030
warn: Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer[100]
      Unhandled exception rendering component: The key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
      System.Security.Cryptography.CryptographicException: The key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)
         at Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector protector, String protectedData)
         at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.Unprotect[TValue](String purpose, String protectedJson)
         at Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage.ProtectedBrowserStorage.GetAsync[TValue](String purpose, String key)
         at Aspire.Dashboard.Model.BrowserStorage.BrowserStorageBase.GetAsync[T](String key) in /_/src/Aspire.Dashboard/Model/BrowserStorage/BrowserStorageBase.cs:line 19
         at Aspire.Dashboard.Components.Pages.PageExtensions.InitializeViewModelAsync[TViewModel,TSerializableViewModel](IPageWithSessionAndUrlState`2 page) in /_/src/Aspire.Dashboard/Components/Pages/IPageWithSessionAndUrlState.cs:line 97
         at Aspire.Dashboard.Components.Pages.Metrics.OnParametersSetAsync() in /_/src/Aspire.Dashboard/Components/Pages/Metrics.razor.cs:line 106
         at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
         at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
         at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]
      Unhandled exception in circuit 'Y26sL1APnooubMP0bLXR0GTwq7nKK6t3vyMQ1yUMzZk'.
      System.Security.Cryptography.CryptographicException: The key {c02a08ff-c2ae-4876-a796-ced22b2fa4ac} was not found in the key ring. For more information go to https://aka.ms/aspnet/dataprotectionwarning
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte[] protectedData, Boolean allowOperationsOnRevokedKeys, UnprotectStatus& status)
         at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte[] protectedData)

@joperezr joperezr added untriaged New issue has not been triaged area-dashboard labels Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-dashboard untriaged New issue has not been triaged
Projects
None yet
Development

No branches or pull requests

2 participants