【发布时间】: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