作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
首先,我是 C# 开发的新手,并尝试将身份验证从基本身份验证切换到基于 oauth 的身份验证。然而,在测试下面的代码时,我得到了折旧异常。
#实现
// Using Microsoft.Identity.Client
var cca = ConfidentialClientApplicationBuilder
.Create(clientId) //client Id
.WithClientSecret(clientSecret)
.WithTenantId(tenantId)
.Build();
var ewsScopes = new string[] { "https://outlook.office365.com/.default" };
try
{
// Get token
var authResult = await cca.AcquireTokenForClient(ewsScopes)
.ExecuteAsync();
this.token = authResult.AccessToken;
}
catch (MsalException ex)
{
Console.WriteLine($"Error acquiring access token: {ex}");
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex}");
}
#异常
Microsoft.Identity.Client.MsalServiceException
HResult=0x80131500
Message=AADSTS1002016: You are using TLS version 1.0, 1.1 and/or 3DES cipher which are deprecated to improve the security posture of Azure AD. Your TenantID is: 9XXXXXXXXXXXXXXXXXXf. Please refer to https://go.microsoft.com/fwlink/?linkid=2161187 and conduct needed actions to remediate the issue. For further questions, please contact your administrator.
Trace ID: 57531a5a-2797-4f77-bc73-11b1e4355800
Correlation ID: 4295ecdd-7aa1-458f-8e6a-03fda78ec30f
Timestamp: 2022-07-25 03:32:33Z
Source=Microsoft.Identity.Client
我尝试使用 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 |安全协议(protocol)类型.Tls11 | SecurityProtocolType.Tls;
不幸的是,这不起作用。如果有人可以导航以解决上述异常,我们将不胜感激。
最佳答案
也许这会有所帮助:
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
添加这一行是你的代码启动(必须尽快到达该行),不要费心添加 |安全协议(protocol)类型.Tls11 | SecurityProtocolType.Tls;
它对我有用。
关于c# - 如何在 .NET 中使用 1.2 TLS 版本获取 EWS 服务器的身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73104509/
我是一名优秀的程序员,十分优秀!