C# SSRS DotNet版本和TLS1.2
我在SSRS 2012中使用自定义c#汇编。程序集使用TLS1.2调用另一个REST Web服务。我使用下面的命令在C#汇编中设置协议 在测试环境中,代码运行良好。但在prod env中,它失败了。在prod env中,我收到了这个错误“无法创建SSL/TLS安全通道。”经过分析,我发现唯一的区别是.net framework。在testenv中,我们有4.6,在prod中,我们有4.7。如何使该代码在4.7env中工作?下面是我试过的C# SSRS DotNet版本和TLS1.2,c#,reporting-services,ssrs-2012,C#,Reporting Services,Ssrs 2012,我在SSRS 2012中使用自定义c#汇编。程序集使用TLS1.2调用另一个REST Web服务。我使用下面的命令在C#汇编中设置协议 在测试环境中,代码运行良好。但在prod env中,它失败了。在prod env中,我收到了这个错误“无法创建SSL/TLS安全通道。”经过分析,我发现唯一的区别是.net framework。在testenv中,我们有4.6,在prod中,我们有4.7。如何使该代码在4.7env中工作?下面是我试过的 由于SSRS 2012不支持4.x dotnet,因此c#
ServicePointManager.Expect100Continue = true;
ServicePointManager.DefaultConnectionLimit = 9999;
var hr = (HttpWebRequest)WebRequest.Create(url);
try
{
ServicePointManager.SecurityProtocol = (SecurityProtocolType)( 0xc00);
}
catch (NotSupportedException)
{ //try TLS 1.2
try
{ //try TLS 1.2
Logger.Log("TLS 1.2");
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072
| (SecurityProtocolType)768
| SecurityProtocolType.Tls;
}
catch (NotSupportedException)
{
try
{
Logger.Log("TLS 1.1");
ServicePointManager.SecurityProtocol = (SecurityProtocolType)768
| SecurityProtocolType.Tls;
}
catch (NotSupportedException)
{ //TLS 1.0
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;
}
}
}