I ve faced with very strange issue that i
m正在掙扎2天。我試圖在幾個開發機器上運行下面的代碼,並且它正在成功運行。但是,當我嘗試使用Windows Server 2008 R2生產服務器上運行它 - 它失敗消息:無法在Windows Server 2008 R2上創建SSL/TLS安全通道
無法建立SSL/TLS安全通道
下面是代碼示例:
try
{
Console.WriteLine(ServicePointManager.SecurityProtocol);
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls |
SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
ServicePointManager.Expect100Continue = true;
ServicePointManager.ServerCertificateValidationCallback +=
(sender, certificate, chain, sslPolicyErrors) => true; // ignoring certificate errors
Console.WriteLine(ServicePointManager.SecurityProtocol);
using (var client = new WebClient())
{
client.DownloadString("https://smlegacygateway-integration.mysmartmove.com/LandlordApi/v1/ServerTime");
}
}
catch (Exception ex)
{
Console.WriteLine("Something goes wrong");
Console.Write(ex);
}
Console.WriteLine("Everything is fine.");
Console.ReadLine();
您能否幫我解釋爲什麼只有在Windows Server 2008 R2上失敗?我試圖在Windows Server 2012上運行它 - 一切都很好。
P.S.我運行這個控制檯應用程序與管理權限,所以它不應該涉及任何權利差距 在此先感謝。