When I try to connect to a website I get the error:
The request was aborted: Could not create SSL/TLS secure channel
The Status in the exception is SecureChannelFailure, the Response is null.
Searching StackOverflow for answers has not helped me so far. I tried all the solutions:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.Expect100Continue = true;
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
The ServerCertificateValidationCallback never gets called.
I can open the website in Firefox and Edge(Chromium) without problems, but the Internet Explorer can't make a secure connection to it. So I assume that HttpWebRequest is using the same "mechanics" as Internet Explorer, but I can't figure out which.
On https://server.cryptomix.com/secure/ I ensured, that I don't have a client SSL certificate presented. That means that I don't have to add ClientCertificate to the request.
Here is my whole test code:
public static void Main()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
ServicePointManager.Expect100Continue = true;
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(@"https://netmap.vodafone.de"));
request.Method = "GET";
request.ContentType = "text/json";
try
{
using (var response = (HttpWebResponse)request.GetResponse())
{
}
}
catch (Exception e)
{
throw;
}
}
Do you have any idea, why I can connect with Internet Explorer and HttpWebRequest, but with Firefox it's possible?
Do you get the same error when you run the code?
Edit: I found out, that the website is using TLS 1.3, but there is no SecurityProtocolType.Tls13 enum value.