【发布时间】:2020-07-14 08:29:30
【问题描述】:
我正在尝试使用 nginx 运行时相关将我的 .net core 3.1 项目部署到 debian。我在 Windows 上开发它,调试时一切正常。但是,由于这个错误,在生产中我遇到了 502;
System.InvalidOperationException: Type '' is not supported.
at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureClients.GetClients()+MoveNext()
at Microsoft.AspNetCore.ApiAuthorization.IdentityServer.ConfigureClients.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()
我尝试像这样向 identityServer 添加签名凭据;
var bytes = File.ReadAllBytes("/etc/myapp/IdentityServerCertificate.pfx");
var cert = new X509Certificate2(bytes, "PWD");
identityServer.AddSigningCredential(cert);
我还在 appsettings.json 中添加了 IdentityServer 的密钥;
"IdentityServer": {
"Clients": {
"MyClient": {
"Profile": "IdentityServerSPA"
},
"Key": {
"Type": "File",
"FilePath": "/etc/myapp/IdentityServerCertificate.pfx",
"Password": "PWD"
}
},
但它没有用。这似乎是与 GetClients() 方法而不是证书相关的问题。我还尝试通过代码配置客户端。还有什么想法吗?谢谢!
【问题讨论】:
-
你能显示GetClients方法的内容吗?那里似乎有什么问题。
-
请查看@nahidf 分享下方的github链接。
标签: asp.net-core nginx .net-core debian identityserver4