ssl - Windows 应用商店应用程序 : The host name in the certificate is invalid or does not match

标签 ssl windows-store-apps windows-8.1

在我的 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/

相关文章:

windows-runtime - 如何确定 GridView 中的哪些项目在当前滚动窗口中可见?

c# - 后台下载器找不到文件异常

c# - 我的项目无法使用 System.Diagnostics.Process

c# - Windows 8 中是否有任何特殊的 API 来挂载 ISO 文件?

web-services - 如何知道 2 个服务器之间的信息是否安全(SSL)?

ssl - 本地 Service Fabric 使用第三方 CA 证书的安全集群

与 .AsInputStream() 转换流一起使用时的 C# DataReader 问题

c++ - 在 Qt 中编译应用程序时出现 "SHIMVIEW:Shiminfo(complete)"消息

svn - 将 SSL 支持添加到 docker 容器

ssl - 是否可以在不导航到 IIS :\SSLBindings 的情况下创建 SSLBinding