客户端证书 Windows Phone 8.1

编程入门 行业动态 更新时间:2024-10-28 10:21:21
本文介绍了客户端证书 Windows Phone 8.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

Windows Phone 8.1 是否支持向 HTTP Web 请求添加客户端证书?我正在尝试执行与以下类似的操作,但我似乎无法确定在 WP8.1 上什么(如果有)与此等效:

Does Windows Phone 8.1 support adding a client certificate to an HTTP web request? I'm trying to do something similar to the following, but I can't seem to determine what (if any) is the equivalent to this on WP8.1:

System.Net.HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
request.ClientCertificates.Add(certificate);

谢谢.

推荐答案

我假设您已经将客户端证书放在应用程序证书存储中.如果不是这就是你必须这样做的方式1) 下载 PFX 文件.2) 使用以下方式将其安装在应用程序的证书库中

I assume that you have already put the client certificate in app certificate store. If not this is how you will have to do that 1) Download the PFX file. 2) Install it in the App's certificate store using the following way

await CertificateEnrollmentManager.ImportPfxDataAsync(certString, "Your_PFX_Password", ExportOption.Exportable, KeyProtectionLevel.NoConsent, InstallOptions.None, friendlyName);

3) 下一步是在证书存储中查找证书.这是按如下方式完成的

3) The next step is to look for the certificate in certificate store. This is done as below

CertificateQuery certQuery = new CertificateQuery();
certQuery.FriendlyName = friendlyName;
IReadOnlyList<Certificate> certs = await CertificateStores.FindAllAsync(certQuery)

certs[0] 将拥有证书

The certs[0] will have the certificate

4) 将证书附加到 HTTP 请求中

4) To attach the certificate to HTTP request

HttpBaseProtocolFilter protolFilter = new HttpBaseProtocolFilter();
protolFilter.ClientCertificate = certs[0] //from previous step
HttpClient client = new HttpClient(protolFilter)

需要注意的是你不应该使用 System.Net.htpp.HttpClient.相反,您应该使用 Windows.Web.Http.HttpClient.

Point to note is you should not use System.Net.htpp.HttpClient. Instead you should you Windows.Web.Http.HttpClient.

这篇关于客户端证书 Windows Phone 8.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-25 22:57:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1124927.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端   证书   Windows   Phone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!