IdentityServer4 - 发生安全错误

时间:2017-09-05 10:48:20

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

我正在使用IdentityServer4和ASP .NET Core WebAPI,我遇到以编程方式访问发现页面的问题

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

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

因此,我开始在服务器的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.

异常StackTrace

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

内部异常StackTrace

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

编辑01 将来自服务器的相同自签名证书添加到我的笔记本电脑上的部分可以正常运行。

1 个答案:

答案 0 :(得分:0)

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

完成了这项工作