问题
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 ?
回答1:
Try:
filter.IgnorableServerCertificateErrors.Add(
ChainValidationResult.Untrusted |
ChainValidationResult.InvalidName);
For more certificate ooptions take a look at ChainValitadionResult enumeration
来源:https://stackoverflow.com/questions/23868488/windows-store-apps-the-host-name-in-the-certificate-is-invalid-or-does-not-matc