Sunday, February 23, 2014

HttpRequest with SSL

Have this code:


The problem is that internet browser show popup "Do you want to use this certificate...", but in my application this message doesn't show up, why?


In addition i can say that on other PC all works fine - same project.


All needed capabilities are set. I repeat that this same project works fine on 3 other computers and builds are working fine on test tablets.



private async void Button_Click(object sender, RoutedEventArgs e)
{
String url = "https://URL"; //hidden in security purpose
HttpClientHandler aHandler = new HttpClientHandler();
aHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;
HttpClient aClient = new HttpClient(aHandler);
aClient.DefaultRequestHeaders.ExpectContinue = false;
aClient.DefaultRequestHeaders.MaxForwards = 3;
Uri requestUri = new Uri(url);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUri);
var result = await aClient.GetAsync(requestUri, HttpCompletionOption.ResponseContentRead);
var responseHeader = result.Headers;
var responseBody = await result.Content.ReadAsStringAsync();

}







Foma


No comments:

Post a Comment