我已经完成了如何在localhost上使用https/SSL中详述的步骤?但这会为我的机器名设置一个自签名证书,当通过https:// localhost浏览时,我会收到IE警告.
有没有办法为"localhost"创建自签名证书以避免此警告?
我使用 .NET 5.0 RC1 Framework 创建了一个托管在 .NET Core 应用程序中的简单 Blazor Web 程序集项目,并在 Visual Studio 2019 预览版的向导期间添加了授权。它在调试中完美运行,但如果我发布它并尝试连接到服务器,我会收到 500 错误。检查日志错误是:
Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HM37MQFV38CV", Request id "0HM37MQFV38CV:00000003": An unhandled exception was thrown by the application.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Extensions.DependencyInjection.IdentityServerBuilderConfigurationExtensions.<>c.<AddSigningCredentials>b__10_2(IServiceProvider sp)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitRootCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitIEnumerable(IEnumerableCallSite enumerableCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitNoCache(ServiceCallSite callSite, TArgument …Run Code Online (Sandbox Code Playgroud) blazor visual-studio-2019 .net-5 blazor-webassembly blazor-hosted
我将IdentityServer4与来自ASP.NET Core 3.0的React启动项目一起使用。预览4,它可以完美工作,直到我构建解决方案并尝试使用dotnet命令从cmd提示符运行它。每次我启动应用程序时,它都会告诉我未指定密钥类型。
我没有尝试过各种有关生成证书的指南,因为我对.NET没有任何经验。我提到这一点是为了防止问题可能是由错误的证书生成方式引起的。
我也尝试过将密钥类型添加到Appsettings.json中,但我不知道该类型可能是什么。我整天都在Google上寻找有关如何配置IdentityServer4进行部署的文档,但是似乎没有人遇到这个问题或需要任何帮助来生成正确的证书。
只要指定它是开发环境,就可以在Visual Studio中运行该应用程序。
当我切换到生产环境或构建解决方案并从命令提示符运行它时,将发生以下堆栈跟踪:
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using 'C:\Users\username\AppData\Local\ASP.NET\DataProtection-Keys' as key repository and Windows DPAPI to encrypt keys at rest.
info: IdentityServer4.Startup[0]
Starting IdentityServer4 version 3.0.0.0
info: Microsoft.Extensions.DependencyInjection.ConfigureApiResources[0]
Configuring local API resource 'Codellic.WebAPI'.
Application startup exception: System.InvalidOperationException: Key type not specified.
at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureSigningCredentials.LoadKey()
at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureSigningCredentials.Configure(ApiAuthorizationOptions options)
at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)
at Microsoft.Extensions.Options.OptionsManager`1.<>c__DisplayClass5_0.<Get>b__0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Microsoft.Extensions.Options.OptionsCache`1.GetOrAdd(String name, Func`1 createOptions)
at Microsoft.Extensions.Options.OptionsManager`1.Get(String name)
at Microsoft.Extensions.Options.OptionsManager`1.get_Value() …Run Code Online (Sandbox Code Playgroud)