在我的 Windows 8.1 应用程序中,当我调用 Web 服务时,出现以下异常:
The host name in the certificate is invalid or does not match
我使用的代码:
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();
我正在使用 HttpBaseProtocolFilter 来绕过服务器证书可能出现的错误,但它似乎并没有克服上述异常。
有什么解决方法吗?
最佳答案
尝试:
filter.IgnorableServerCertificateErrors.Add(
ChainValidationResult.Untrusted |
ChainValidationResult.InvalidName);
有关更多证书选项,请查看 ChainValitadionResult enumeration
关于ssl - Windows 应用商店应用程序 : The host name in the certificate is invalid or does not match,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23868488/