Skip to content

Instantly share code, notes, and snippets.

@benhysell
Created January 28, 2015 03:08
Show Gist options
  • Save benhysell/10c1eb546bd3401ee50f to your computer and use it in GitHub Desktop.
Save benhysell/10c1eb546bd3401ee50f to your computer and use it in GitHub Desktop.
c# HttpClient Ignore Certificate - for local certificates
using (var client = new HttpClient())
{
ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
var response = await client.GetAsync(reqUrl);
response.EnsureSuccessStatusCode();
if (!Convert.ToBoolean(await response.Content.ReadAsStringAsync()))
throw new Exception("Response from webserver was false.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment