I have been using
HttpClient httpClient = new HttpClient();
httpClient.BaseAddress = new Uri("http://foobar.com/");
var task = httpClient.PostAsXmlAsync<DeviceRequest>("api/SaveData", request);
The underlying connection was closed: Could not establish trust
relationship for the SSL/TLS secure channel.
How do I supply certificate & public / private key along with C#
Simply specify HTTPS in the URI.
Foobar.com will need to have a trusted SSL cert or your calls will fail with untrusted error.
EDIT Answer: ClientCertificates with HttpClient
WebRequestHandler handler = new WebRequestHandler(); X509Certificate2 certificate = GetMyX509Certificate(); handler.ClientCertificates.Add(certificate); HttpClient client = new HttpClient(handler);
EDIT Answer2: If the server you are connecting to has disabled SSL, TLS 1.0, and 1.1 and you are still running .NET framework 4.5(or below) you need to make a choice