SEC_ERROR_INADEQUATE_KEY_USAGE on accessing webapp published using Visual Studio
Asked Answered
M

4

10

I created a Blazor Server webapp and published it from Visual Studio using right click on the project - publish. I am publishing to a local folder, amongst others the output includes MyProject.exe Running that works fine:

info: Microsoft.Hosting.Lifetime[0]
      Now listening on: http://localhost:5000
info: Microsoft.Hosting.Lifetime[0]
      Now listening on: https://localhost:5001
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production

However I can not access my webapp on https://localhost:5001. Firefox gives me the error code SEC_ERROR_INADEQUATE_KEY_USAGE. There is no option to ignore it. Accessing it using Chrome just gives me HTTP ERROR 500. In the console where I started MyProject.exe I can find this error:

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.InvalidOperationException: Cannot find the fallback endpoint specified by route values: { page: /_Host, area:  }.
         at Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DynamicPageEndpointMatcherPolicy.ApplyAsync(HttpContext httpContext, CandidateSet candidates)
         at Microsoft.AspNetCore.Routing.Matching.DfaMatcher.SelectEndpointWithPoliciesAsync(HttpContext httpContext, IEndpointSelectorPolicy[] policies, CandidateSet candidateSet)
         at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.<Invoke>g__AwaitMatch|8_1(EndpointRoutingMiddleware middleware, HttpContext httpContext, Task matchTask)
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[3]

Can anyone help me with this? And yes, it's a private application and shall run locally on localhost. When I run my webapp from Visual Studio, everything works fine.

Mayest answered 3/9, 2020 at 14:28 Comment(1)
I have this problem after updating to Visual Studio 2019 Prerelease (.net core 5.0)Uncertainty
H
12

I got the SEC_ERROR_INADEQUATE_KEY_USAGE error too when trying to debug my .Net 6 app with Visual Studio and Firefox. It worked fine on other browsers, just not Firefox. I found the answer on Super User here. Your question mentions that you can debug without issues, but perhaps this solution will still work for you.

Visual Studio generates its own CA and installs it into the Windows Certificate store for web development. You can configure Firefox to import CAs from the Windows Certificate Store by enabling the ImportEnterpriseRoots setting in Firefox.

Do the following to enable use of the Windows Certificate Store by Firefox:

  1. Open Firefox
  2. Navigate to "about:config"
  3. Search for "ImportEnterpriseRoots"
  4. Add it, setting it to true
  5. Restart Firefox (if you have multiple instances open, you must close them all)
Harilda answered 22/4, 2022 at 7:28 Comment(1)
ImportEnterpriseRoots is the old name and is used in the enterprise policy template. The current setting is security.enterprise_roots.enabledGotcher
E
9

I had a similar problem with the Angular proxy with an aspnetcore back end. The solution for me was to delete the certificate and key used by the proxy located in:

%AppData%\ASP.NET\https

The proxy then regenerates a new certificate and can carry on as normal.

Elliellicott answered 25/5, 2022 at 10:36 Comment(1)
I tried all the suggested fixes for FF with no success. Deleting the cert and letting the proxy regenerate was the solution.Ret
E
1

You can skip this error by copying your development certificates from the Personal category into the Trusted Root Certificates.

Open the certificates window. See how to open it https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-view-certificates-with-the-mmc-snap-in

Then copy your development certificates as shown in the picture enter image description here

Eugenioeugenius answered 23/11, 2020 at 13:53 Comment(0)
D
0

You can use the button on the "Help -> More Troubleshooting Information" (about:support) page to go to the current Firefox profile folder or use the about:profiles page (Root directory). Try to rename/remove cert9.db in the Firefox profile folder with Firefox closed.

Deadeye answered 19/12, 2023 at 3:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.