猿问

无法从以下位置检索文档:“https://ids.com/.well-known/openid

我一直在开发多个依赖 Identity Server 4(IDS4) 使用 OIDC 进行身份验证的应用程序。一切都很好,直到我使用 SSL 卸载将应用程序放在代理后面。


目标是能够访问一个站点。当您请求登录时,它应该将您重定向到 IDS4 验证您,然后将您送回。这是标准的。。


真正发生了什么。403 错误:


An unhandled exception occurred while processing the request.

HttpRequestException: Response status code does not indicate success: 403 (Forbidden).

System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()

IOException: IDX20804: Unable to retrieve document from: 'https://ids.com/.well-known/openid-configuration'.

Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(string address, CancellationToken cancel)

InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https://ids.com/.well-known/openid-configuration'.

Microsoft.IdentityModel.Protocols.ConfigurationManager<T>.GetConfigurationAsync(CancellationToken cancel)

Stack Query Cookies Headers 

HttpRequestException: Response status code does not indicate success: 403 (Forbidden).

System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()

Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(string address, CancellationToken cancel)


只是出于好奇,我关闭了我的 IDS 应用程序并尝试通过我的其他应用程序之一访问它并得到完全相同的错误响应。这让我相信这与使用 openidc 时我的应用程序中的代码或我的 IIS 设置有关。


注意事项:我使用的是 IIS。我的代理站点上有一个受信任的 CA 证书。假设 IDS 正在运行,我可以在我的浏览器中访问“ https://ids.com/.well-known/openid-configuration ”。你不会的,这是一个假域名。


我尝试过的事情:


在 OpenIdConnect 内部尝试将 RequireHttpsMetadata 从 false 切换为 true,


app.UseForwardedHeaders();


好的,我在这里肯定是错的,但我认为问题在于我的应用程序(使用 OIDC 时)没有发送 SSL 信息,该信息禁止他们访问“ https://ids.com/.well-know ”地址。


我应该从哪里开始尝试使用它?


慕斯王
浏览 337回答 3
3回答

慕姐4208626

对我来说,问题通过添加解决了ServicePointManager.SecurityProtocol&nbsp;=&nbsp;SecurityProtocolType.Tls12

米琪卡哇伊

我终于解决了这个问题。我知道这与证书有关,但我不确定该怎么做。我的解决方法是将 options.BackchannelHttpHandler 添加到private readonly HttpClientHandler _handler;public Startup(IHostingEnvironment env, IConfiguration config,&nbsp; &nbsp; ILoggerFactory loggerFactory)&nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; _env = env;&nbsp; &nbsp; &nbsp; &nbsp; _config = config;&nbsp; &nbsp; &nbsp; &nbsp; _loggerFactory = loggerFactory;&nbsp; &nbsp; &nbsp; &nbsp; Configuration = config;&nbsp; &nbsp; &nbsp; &nbsp; _handler = new HttpClientHandler();&nbsp; &nbsp; &nbsp; &nbsp; _handler.ClientCertificates.Add(FindClientCertificate());//same x509cert2 that proxy server uses&nbsp; &nbsp; &nbsp; &nbsp; _handler.AllowAutoRedirect = true;&nbsp; &nbsp; }.....AddOpenIdConnect( scheme, options => {....options.BackchannelHttpHandler = _handler;...}

qq_笑_17

花了一个不眠之夜来解决这个问题。下面的代码解决了我的问题。服务 .AddIdentityServer(options => {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.IssuerUri&nbsp;=&nbsp;<Authority&nbsp;Url>;&nbsp;//<==&nbsp;Added&nbsp;this&nbsp;one&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.Events.RaiseSuccessEvents&nbsp;=&nbsp;true; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.Events.RaiseFailureEvents&nbsp;=&nbsp;true; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options.Events.RaiseErrorEvents&nbsp;=&nbsp;true; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})
随时随地看视频慕课网APP
我要回答