Reputation: 10971
in my windows 8.1 application, when I call a web service, I get the following exception:
The host name in the certificate is invalid or does not match
The code I use:
HttpBaseProtocolFilter filter = new HttpBaseProtocolFilter();
filter.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
HttpClient client = new HttpClient(filter);
HttpResponseMessage msg = await client.GetAsync(new Uri("[Service_URL]",UriKind.Absolute));
IRandomAccessStream randomAccessStream=(IRandomAccessStream)await msg.Content.ReadAsInputStreamAsync();
I'm using the HttpBaseProtocolFilter to bypass the errors that could be with the server's certificate, but it seems that it does not overcome the above exception.
Is there any workaround for this ?
Upvotes: 3
Views: 2327
Reputation: 16420
Try:
filter.IgnorableServerCertificateErrors.Add(
ChainValidationResult.Untrusted |
ChainValidationResult.InvalidName);
For more certificate ooptions take a look at ChainValitadionResult enumeration
Upvotes: 7