当我尝试从ASP.NET请求Web时,在SPA核心中收到net::ERR_CERT_AUTHORITY_INVALID
错误。
解决这个问题的第一个解决方案是从浏览器Advanced
- Proceed to localhost (unsafe)
转到我的SPA核心地址,然后我的ASP.NET的请求就可以工作了。但每次我开始做我的项目时,我都必须重复这个过程。
我找到的另一个解决方案是this。简而言之,解决方案是运行命令:dotnet dev-certs https --trust
。我在Windows上,所以根据链接的文章On Windows it'll get added to the certificate store
。
但是在我运行该命令之后,我仍然收到请求的net::ERR_CERT_AUTHORITY_INVALID
问题。我能做些什么呢?
发布于 2020-09-09 12:42:32
在您的应用程序中,通过NuGet包添加对Microsoft.AspNetCore.Authentication.Certificate的引用。然后在Startup.ConfigureServices方法中编写以下代码:
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(
CertificateAuthenticationDefaults.AuthenticationScheme)
.AddCertificate();
// All other service configuration
}
还要在Startup.Configure方法中添加app.UseAuthentication();。否则,HttpContext.User将不会设置为ClaimsPrincipal
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseAuthentication();
// All other app configuration
}
来源:https://docs.microsoft.com/en-us/aspnet/core/security/authentication/certauth?view=aspnetcore-3.1
发布于 2021-09-26 14:33:13
我遵循了这些步骤,但它并没有阻止Chrome中出现“不安全”的消息。因此,我尝试在startup.cs的Configure()方法中注释以下行//app.UseHttpsRedirect();,它解决了这个问题。
https://stackoverflow.com/questions/63796566
复制相似问题