加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows-store-apps – 如何信任Windows商店应用程序中的自签名

发布时间:2020-12-13 20:22:59 所属栏目:Windows 来源:网络整理
导读:我试图在Windows Store App中覆盖证书验证,以接受两个外部服务(使用HttpClient)上的自签名证书,以允许Windows 8应用程序接受证书并建立SSL的信任关系 编辑: 我实施了这里记载的方法:Installing certs by using the appmanifest 并将相关的.cer文件添加到我
我试图在Windows Store App中覆盖证书验证,以接受两个外部服务(使用HttpClient)上的自签名证书,以允许Windows 8应用程序接受证书并建立SSL的信任关系

编辑:
我实施了这里记载的方法:Installing certs by using the appmanifest

并将相关的.cer文件添加到我的应用程序中,并确保它们是“内容”和“始终复制”.

我的package.appxmanifest扩展部分如下所示:

<Extensions>
<Extension Category="windows.certificates">
  <Certificates>
    <Certificate StoreName="TrustedPeople" Content="AssetsReportingServices.cer" />
    <Certificate StoreName="TrustedPeople" Content="AssetsCrm.cer" />
    <Certificate StoreName="CA" Content="AssetsDigiCertHighAssurance.cer" />
    <TrustFlags ExclusiveTrust="true" />
    <SelectionCriteria AutoSelect="true" />
  </Certificates>
</Extension>

但这还是不行.

我已经尝试将应用程序证书放在“根”StoreName中,但仍然没有成功.有没有人有任何想法为什么这可能不工作吗?

这是一个老的,但看到有不少观察者,我会给我的解决方案.
// Create the httpClient and send the request
HttpBaseProtocolFilter aHBPF = new HttpBaseProtocolFilter();
// If you want to ignore expired Certs
aHBPF.IgnorableServerCertificateErrors.Add(ChainValidationResult.Expired);
// Untrused because this is a self signed cert that is not installed
aHBPF.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
// Host names and certs names may not match
aHBPF.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);

HttpClient httpClient = new HttpClient(aHBPF);
HttpResponseMessage response = await httpClient.SendRequestAsync(httpRequest,HttpCompletionOption.ResponseHeadersRead).AsTask(cts.Token);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读