I'm trying to use RestSharp to call the local Bosch Smart Home API. The Documentation by Bosch shows how to use Postman to HTTP-Request the local API, wich all functions properly. I can even request a Device-List, after creating a self-signed Certificate and setting Postman up accordingly. So I tried to develop a simple C# Code to request the same list via RestSharp.
static void RestGet()
{
System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
const String WEBSERVICE_URL = "https://10.20.1.41:8444/smarthome/devices";
const string certificate_path = @"C:\Users\niko\Documents\certificates\certificate.pfx";
const string certificate_pass = "....";
const string systemPassword = "...."; //encrypted in BASE64
string ua = "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0";
ServicePointManager.Expect100Continue = true;
ServicePointManager.DefaultConnectionLimit = 9999;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
var client = new RestClient("https://10.20.1.41:8444/smarthome/devices");
client.Timeout = 100000;
X509Certificate2 cer = new X509Certificate2(certificate_path, certificate_pass);
client.ClientCertificates = new X509CertificateCollection() { cer };
var request = new RestRequest(Method.GET);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("api-version", "1.0");
request.AddHeader("Systempassword", systemPassword);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.ErrorMessage);
Console.WriteLine(response.Content);
Console.ReadKey();
}
For some reason the Server just sends the ErrorMessage "The request was aborted: Could not create SSL/TLS secure channel.". I've been trying to figure it out for the whole day, but since the API is pretty new, there isn't any info up about it yet.