windows-phone-8.1 – 升级到最新Windows Phone 8.1后无法发送证书
|
我有一个为8.1创建的Windows Phone应用程序,其中一个任务是客户端 – 服务器证书方案。我的应用程序工作正常,我可以发送客户端证书并登录到服务器。但升级到Windows 8.10.14xxxx之后是不可能的。我拿了wirehark的踪迹,似乎证书从不发送。
我使用HttpClient.SendAsync(await)和HttpBaseProtocolFilter输入证书。升级前它工作完美。 任何想法?有什么坏处吗 首先我正在安装pfx async private void btnInstall_Click(object sender,RoutedEventArgs e)
{
//Install the self signed client cert to the user certificate store
string CACertificate = null;
try
{
Uri uri = new Uri("ms-appx:///certificates/test.pfx");
var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);
IBuffer buffer = await FileIO.ReadBufferAsync(file);
using (DataReader dataReader = DataReader.FromBuffer(buffer))
{
byte[] bytes = new byte[buffer.Length];
dataReader.ReadBytes(bytes);
// convert to Base64 for using with ImportPfx
CACertificate = System.Convert.ToBase64String(bytes);
}
await CertificateEnrollmentManager.UserCertificateEnrollmentManager.ImportPfxDataAsync(
CACertificate,"xxxxx",ExportOption.Exportable,KeyProtectionLevel.NoConsent,InstallOptions.None,"ClientCert1");
}
catch (Exception ex)
{
//;
}
}
然后我打电话给这个服务 string serviceURL = "https://my.web.services";
Certificate cert = null;
CertificateQuery query = new CertificateQuery();
query.FriendlyName = "ClientCert1";
IReadOnlyCollection<Certificate> certs = await CertificateStores.FindAllAsync(query);
HttpBaseProtocolFilter bpf = new HttpBaseProtocolFilter();
//if you install the CA you don't need to ignore the ServerCertificate Errors
//bpf.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
if (certs.Count > 0)
{
cert = certs.ElementAt(0);
bpf.ClientCertificate = cert;
}
HttpClient httpClient = new HttpClient(bpf);
try
{
var response = await httpClient.GetInputStreamAsync(new Uri(serviceURL));
//take data
}
catch (Exception ex)
{
//0x80072F0D
}
在8.10.14xxxx Windows Phone中运行时,我总是采取一个例外(0x80072F0D)。我的代码在更新之前工作,现在我总是使用这个返回码。证书被加载到httpClient中。当我用调试器停止应用程序似乎证书在那里,但是0x800072F0D可能意味着证书没有发送? 在场景中有一个中间证书颁发机构。该证书包含在pfx中。我需要安装吗? 我假设您已经将客户端证书放在应用程序证书存储中。如果不这样做: 1)下载PFX文件。 2)通过以下方式将证书安装在应用程序的证书库中 await CertificateEnrollmentManager.ImportPfxDataAsync(certString,"Your_PFX_Password",friendlyName); 3)检查证书库中的证书。 CertificateQuery certQuery = new CertificateQuery(); certQuery.FriendlyName = friendlyName; IReadOnlyList<Certificate> certs = await CertificateStores.FindAllAsync(certQuery); 证书[0]应该有你需要的证书。 4)现在,将证书附加到HTTP请求 HttpBaseProtocolFilter protolFilter = new HttpBaseProtocolFilter(); protolFilter.ClientCertificate = certs[0] //from previous step HttpClient client = new HttpClient(protolFilter) PS:你不应该使用System.Net.htpp.HttpClient。而不是应该使用Windows.Web.Http.HttpClient。 (编辑:南阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 如何在Windows上确定是否安装了C/C++编译器
- adodb – Windows脚本宿主(jscript):我如何下载二进制文件
- 如何在Windows中挂钩应用程序和进程启动?
- windows – procdump -t – 如何在进程终止时转储 – 使用?
- windows – 在matlab中监视内存
- assembly – windows进程内存布局
- .net – 为什么我无法在2.0.0.0播放器框架中重用1.8.2.2 Pl
- Windows Server 2016-安装AD域服务注意事项
- php在windows环境下获得cpu内存实时使用率(推荐)
- windows – 为什么模拟会话中定义的DOS设备不会出现在资源管
- .net – 在Windows应用程序中格式化标签内的文本
- 无法找到MSVCP120D.DLL或0x00007启动错误的解决方
- windows-runtime – 将Action绑定到XAML中UserCo
- batch-file – 用于在Windows 7中更改屏幕分辨率
- WIN10家庭中文版远程提示要求的函数不支持 win10
- WPF:xaml中的权力
- Vulkan Tutorial 07 Window surface
- tfs – 在测试用例通过或失败时发送电子邮件警报
- windows-phone-8 – Windows Phone 8.1应用程序无
- windows-8 – 地铁样式Windows 8应用程序是否支持
