我将IdentityServer4与ASP一起使用。NET核心WebAPI和我在以编程方式访问发现页面方面遇到问题
var disco = await DiscoveryClient.GetAsync("https://<api>:1337");
HTTPS is required
如果主机名为localhost?
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 certificate容器部分有效。