My goal is to check the file size, I am tested this code on several windows server 2012 r2 machines The following code gives error, (in all of them):
Could not create SSL/TLS secure channel
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);
}
The same code works fine on Windows servers 2016 and on windows 10, but not on windows servers 2012.
when I enter this link from chrome it works even on server 2012, also with postman it works on all machines (but doesn't work via code in windows 2012).
The error happens for then given link, but for other file urls like http://www.orimi.com/pdf-test.pdf it works fine.
I also tried to enable TLS via registry:
any ideas?
