无法创建SSLTLS安全通道的情况只发生在windows server 2012。

问题描述 投票:0回答:1

我的目标是检查文件的大小,我在几个windows server 2012 r2机器上测试了这个代码,下面的代码给出了错误,(在所有的机器上)。

无法创建SSLTLS安全通道

ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
string url = @"https://www.gov.il/BlobFolder/reports/fortimail/he/FORTIMAIL-CERT-IL-W-1068.pdf";
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);            
using (HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse())
{
    var headers = myHttpWebResponse.Headers;
    string fileSize = "0";
    if (headers.AllKeys.Contains("Content-Length"))
        fileSize = headers.GetValues("Content-Length")[0];
    Console.WriteLine(fileSize);
}

同样的代码在Windows服务器2016和windows 10上都能正常工作,但在windows服务器2012上就不行了。

当我从chrome输入这个链接时,即使在2012年服务器上也能正常工作,也可以用postman在所有机器上工作(但在windows 2012中通过代码无法工作)。

该错误发生在给定的链接上,但对于其他文件URL,如 http://www.orimi.com/pdf-test.pdf 它工作正常。

我也尝试通过注册表启用TLS。

enter image description here

有什么想法吗?

ssl tls1.2 windows-server-2012 windows-server-2012-r2
1个回答
0
投票

尝试纠正配置为。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

这样应该就可以了 该网站只支持TLS1.2,这是目前广泛支持的TLS版本。

Windows 2012可能会做到TLS 1.0开箱即用。建议应用所有的windows更新和编辑系统设置,默认只做TLS 1.2。你的这些注册表键是正确的,但还有更多。微软文档对配置没有很大的解释,可能会找到一个堆栈溢出来解释这些调整。

Windows 2012 R2在2018年达到了支持的终点,它将在2023年达到扩展支持的终点(假设你每年为它支付额外的费用)。你应该考虑升级。预计Windows 2008和2012上过时的加密技术将成为TLS连接问题的经常性来源。

curl "https://www.gov.il/BlobFolder/reports/fortimail/he/FORTIMAIL-CERT-IL-W-1068.pdf" --tlsv1.2
... good

curl "https://www.gov.il/BlobFolder/reports/fortimail/he/FORTIMAIL-CERT-IL-W-1068.pdf" --tlsv1.1
curl: (35) schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326)
This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed). More detail may be available in the Windows System event log.

curl "https://www.gov.il/BlobFolder/reports/fortimail/he/FORTIMAIL-CERT-IL-W-1068.pdf" --tlsv1.0
curl: (35) schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326)
This error usually occurs when a fatal SSL/TLS alert is received (e.g. handshake failed). More detail may be available in the Windows System event log.
© www.soinside.com 2019 - 2024. All rights reserved.