Created
January 28, 2015 03:08
-
-
Save benhysell/10c1eb546bd3401ee50f to your computer and use it in GitHub Desktop.
c# HttpClient Ignore Certificate - for local certificates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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