I have an incredibly simple web request with RestSharp:
var client = new RestClient("https://website.net");
var request = new RestRequest("/process", Method.GET);
request.AddParameter("cmd", "execute");
IRestResponse response = client.Execute(request);
var content = response.Content;
Console.WriteLine("Response: " + content);
This returns the error message:
The request was aborted: Could not create SSL/TLS secure channel
Three things:
- I get the response I expect through a browser,
- I get the response I expect through Postman,
- This request is being sent to a test environment, but I can send it to a production environment, which has a very similar address, and get the response I expect,
- I'm positive it worked before today.
Their certificate is using TLS 1.2 with AES 128, so it is unrelated to errors caused by RC4.
This is on my local Win 10 machine in Visual Studio 2015 with a target framework of .NET 4.5.2.
Why do I get this error?
EDIT:
By changing my code to use the base System.Net and the WebRequest class and adding the line:
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
as suggested from here, it works. So I guess RestSharp is using the incorrect protocol for some reason?