【问题标题】:IdentityServer4 - A security error has occuredIdentityServer4 - 发生安全错误
【发布时间】:2018-02-13 15:21:09
【问题描述】:

我将 IdentityServer4 与 ASP .NET Core WebAPI 结合使用,但在以编程方式访问发现页面时遇到问题

var disco = await DiscoveryClient.GetAsync("https://<api>:1337");

如果我在我的本地主机上托管 API(IdentityServer 和受保护的 API),一切正常,我什至不需要使用 https.... 可能它不会抛出 ..HTTPS is required 如果主机的名称是本地主机?

因此,我开始在服务器的 IIS 上创建自签名证书,并将其存储在个人证书存储中。 但是当我从外部(浏览器)连接时,我得到了错误:

This site is not secure - Error Code: DLG_FLAGS_SEC_CERT_CN_INVALID 

经过一番搜索但没有找到任何东西,我在笔记本电脑上安装了相同的证书(因此我可以访问 API 而不会收到警告)。 现在我没有收到任何警告,并且发现 JSON 可用。可见(从浏览器)

但以编程方式我仍然得到同样的错误。

错误

Error connecting to https://:1337/.well-known/openid-configuration: An error occurred while sending the request.

异常堆栈跟踪

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.DiagnosticsHandler.<SendAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
   at System.Net.Http.HttpClient.<FinishSendAsyncBuffered>d__58.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at IdentityModel.Client.DiscoveryClient.<GetAsync>d__17.MoveNext()

InnerException 消息:

A security error occurred

内部异常堆栈跟踪

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Threading.Tasks.RendezvousAwaitable`1.GetResult()
at System.Net.Http.WinHttpHandler.<StartRequest>d__105.MoveNext()

编辑 01 将相同的自签名证书从服务器添加到我的笔记本电脑到 Trusted certify 容器中,部分可行。

【问题讨论】:

    标签: asp.net ssl asp.net-web-api restful-authentication identityserver4


    【解决方案1】:

    安装自签名证书(用于 IIS)后,我遇到了另一个错误,它与 JWT 签名的自签名证书有关,我必须将权限分配给应用程序池后面的域用户(不是ApplicationPoolIdentity) 用于在证书上读/写。 我是通过 MMC 完成的

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-08-27
    • 2017-10-18
    • 1970-01-01
    • 1970-01-01
    • 2020-03-24
    • 2015-06-23
    • 1970-01-01
    相关资源
    最近更新 更多