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

前端之家收集整理的这篇文章主要介绍了windows-store-apps – 如何信任Windows商店应用程序中的自签名证书前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在Windows Store App中覆盖证书验证,以接受两个外部服务(使用HttpClient)上的自签名证书,以允许Windows 8应用程序接受证书并建立SSL的信任关系

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

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

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

  1. <Extensions>
  2. <Extension Category="windows.certificates">
  3. <Certificates>
  4. <Certificate StoreName="TrustedPeople" Content="Assets\ReportingServices.cer" />
  5. <Certificate StoreName="TrustedPeople" Content="Assets\Crm.cer" />
  6. <Certificate StoreName="CA" Content="Assets\DigiCertHighAssurance.cer" />
  7. <TrustFlags ExclusiveTrust="true" />
  8. <SelectionCriteria AutoSelect="true" />
  9. </Certificates>
  10. </Extension>

但这还是不行.

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

这是一个老的,但看到有不少观察者,我会给我的解决方案.
  1. // Create the httpClient and send the request
  2. HttpBaseProtocolFilter aHBPF = new HttpBaseProtocolFilter();
  3. // If you want to ignore expired Certs
  4. aHBPF.IgnorableServerCertificateErrors.Add(ChainValidationResult.Expired);
  5. // Untrused because this is a self signed cert that is not installed
  6. aHBPF.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
  7. // Host names and certs names may not match
  8. aHBPF.IgnorableServerCertificateErrors.Add(ChainValidationResult.InvalidName);
  9.  
  10. HttpClient httpClient = new HttpClient(aHBPF);
  11. HttpResponseMessage response = await httpClient.SendRequestAsync(httpRequest,HttpCompletionOption.ResponseHeadersRead).AsTask(cts.Token);

猜你在找的Windows相关文章