Windows 应用商店应用:证书中的主机名无效或不匹配 [英] Windows Store Apps: The host name in the certificate is invalid or does not match

查看:124
本文介绍了Windows 应用商店应用:证书中的主机名无效或不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 Windows 8.1 应用程序中,当我调用 Web 服务时,出现以下异常:

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

我使用的代码:

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 来绕过可能与服务器证书有关的错误,但它似乎没有克服上述异常.

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.

有什么解决方法吗?

推荐答案

尝试:

filter.IgnorableServerCertificateErrors.Add(
    ChainValidationResult.Untrusted |
    ChainValidationResult.InvalidName);

有关更多证书选项,请查看 ChainValitadionResult枚举

For more certificate ooptions take a look at ChainValitadionResult enumeration

这篇关于Windows 应用商店应用:证书中的主机名无效或不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆