Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RestSharp: Could not create SSL/TLS secure channel

I'm trying to use RestSharp in Visual Studio 2012 Express on a fresh install of Windows 8.1. The API I'm trying to use supports only RC4-SHA for SSL. The certificate is valid.

var client = new RestClient();
client.BaseUrl = "https://teststore.mybigcommerce.com/api/v2/";
client.Authenticator = new HttpBasicAuthenticator("username", "key");

var request = new RestRequest();
request.Resource = "time.json";

IRestResponse response = client.Execute(bcrequest);

I keep getting an error from the client: The request was aborted: Could not create SSL/TLS secure channel. I thought there were certificate problems, until I finally took a packet capture and discovered there were no cipher suites in common. RC4-SHA is not available on the client end. After installing Windows 7 and running the exact same code, the problem goes away.

Why is RC4-SHA unavailable in RestSharp on Windows 8.1?

like image 985
rtf Avatar asked Sep 22 '13 18:09

rtf


1 Answers

I always add the following line of code before making the initial network connection to solve this issue.

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls11;
like image 147
MicrosoftDude Avatar answered Oct 03 '22 17:10

MicrosoftDude