我试图在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="Assets\ReportingServices.cer" />
- <Certificate StoreName="TrustedPeople" Content="Assets\Crm.cer" />
- <Certificate StoreName="CA" Content="Assets\DigiCertHighAssurance.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);