Just add this bit of code to the httpClientHandler:
// Return `true` to allow certificates that are untrusted/invalid
httpClientHandler.ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
Full code example:
var myPostObj = new {prop1 = 1, porp2 = 2};
using (var httpClientHandler = new HttpClientHandler())
{
// Return `true` to allow certificates that are untrusted/invalid
httpClientHandler.ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
using (var client = new HttpClient(httpClientHandler))
{
var reqAsJson = JsonConvert.SerializeObject(myPostObj);
var content = new StringContent(reqAsJson, Encoding.UTF8, "application/json");
var response = await client.PostAsync(url, content);
return response;
}
}