相关疑难解决方法(0)

IdentityServer4无法在生产环境中使用

我将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)

asp.net reactjs identityserver4

6
推荐指数
2
解决办法
1421
查看次数

标签 统计

asp.net ×1

identityserver4 ×1

reactjs ×1