简体   繁体   English

部署在 IIS 上时 Azure AD 登录失败

[英]Azure AD login failing when deployed on IIS

Azure ad authentication working fine with Visual studio IIS Express. Azure 广告身份验证与 Visual Studio IIS Express 配合良好。 But when publish and deploy in IIS server throwing error.但是在 IIS 服务器中发布和部署时抛出错误。

The application built on .NET core 3.1基于 .NET core 3.1 构建的应用程序

System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'https://login.microsoftonline.com/common/discovery/instance?authorization_endpoint=https://login.microsoftonline.com/common/oauth2/v2.0/authorize&api-version=1.1'.

 ---> System.IO.IOException: IDX20804: Unable to retrieve document from: 'https://login.microsoftonline.com/common/discovery/instance?authorization_endpoint=https://login.microsoftonline.com/common/oauth2/v2.0/authorize&api-version=1.1'.

 ---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.

 ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host..

 ---> System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host.

Firstly, make sure your IIS server has TLS 1.2 support enabled.首先,确保您的 IIS 服务器启用了 TLS 1.2 支持。

Also, enable TLS 1.2 support in your .net core application by adding below in startup, in the beginning of Main method of Program.cs.此外,通过在启动时在 Program.cs 的 Main 方法的开头添加以下内容,在您的 .net 核心应用程序中启用TLS 1.2支持。

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.ServicePointManager.SecurityProtocol;

Read more about TLS update in Azure here此处阅读有关 Azure 中 TLS 更新的更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM