Windows phone 8.1 升级到最新的windows phone 8.1后发送证书失败
我有一个Windows Phone应用程序,是为8.1构建的,其中一个任务是客户端-服务器证书场景。我的应用程序运行良好,我可以发送客户端证书并登录到服务器。但是,在升级到windows 8.10.14xxxx之后,这是不可能的。我记录了wireshark的痕迹,似乎证书从未发送过。 消息的内容长度为0 我使用Windows phone 8.1 升级到最新的windows phone 8.1后发送证书失败,windows-phone-8.1,windows-phone,certificate,windows-10,windows-10-mobile,Windows Phone 8.1,Windows Phone,Certificate,Windows 10,Windows 10 Mobile,我有一个Windows Phone应用程序,是为8.1构建的,其中一个任务是客户端-服务器证书场景。我的应用程序运行良好,我可以发送客户端证书并登录到服务器。但是,在升级到windows 8.10.14xxxx之后,这是不可能的。我记录了wireshark的痕迹,似乎证书从未发送过。 消息的内容长度为0 我使用HttpClient.SendAsync(wait)和HttpBaseProtocolFilter输入证书。它在升级之前工作得非常好 有什么想法吗?有东西坏了吗 首先,我要安装pfx as
HttpClient.SendAsync
(wait)和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
}
string serviceURL=”https://my.web.services";
证书cert=null;
CertificateQuery=新建CertificateQuery();
query.FriendlyName=“ClientCert1”;
IReadOnlyCollection certs=等待CertificateStores.findalAsync(查询);
HttpBaseProtocolFilter bpf=新的HttpBaseProtocolFilter();
//如果安装CA,则不需要忽略服务器证书错误
//bpf.IgnorableServerCertificateErrors.Add(ChainValidationResult.Untrusted);
如果(证书计数>0)
{
cert=certs.ElementAt(0);
bpf.ClientCertificate=证书;
}
HttpClient HttpClient=新的HttpClient(bpf);
尝试
{
var response=wait httpClient.GetInputStreamAsync(新Uri(serviceURL));
//获取数据
}
捕获(例外情况除外)
{
//0x80072F0D
}
在8.10.14xxxx
windows phone中运行时,我总是会进行例外处理(0x80072F0D
)。我的代码在更新之前工作,现在我总是使用这个返回代码。证书已加载到httpClient中。当我用调试器停止应用程序时,证书似乎在那里,但是0x800072F0D
可能意味着证书没有发送
该场景中有一个中间证书颁发机构。该证书包含在pfx中。我需要安装这个吗 我假设您已经将客户端证书放入应用程序证书存储中。 如果没有,则执行以下操作:
1) 下载PFX文件。
2) 通过以下方式在应用程序的证书存储中安装证书
await CertificateEnrollmentManager.ImportPfxDataAsync(certString, "Your_PFX_Password", ExportOption.Exportable, KeyProtectionLevel.NoConsent, InstallOptions.None, friendlyName);
3) 在证书存储中检查证书
CertificateQuery certQuery = new CertificateQuery();
certQuery.FriendlyName = friendlyName;
IReadOnlyList<Certificate> certs = await CertificateStores.FindAllAsync(certQuery);
PS:您不应该使用
System.Net.htpp.HttpClient
。相反,你应该使用Windows.Web.Http.HttpClient
你有复制软件吗?@kiewic你知道这个问题吗?我可以分享一些源代码。是的,我可以看看。你可以在GitHub或其他任何地方安装repo。有什么例外吗?TaskCanceledException或其他任何内容?很抱歉没有提前响应。源代码现在在问题主体上。不,它不起作用。这似乎是正确的过程,我已经在呼叫这些线路(请参阅上面的代码),但是在安装windows phone 8.1 update之后,这些线路无法工作。您使用的是哪种设备?一个建议是,对设备进行硬重置,然后再试一次。您的问题有点奇怪。它是诺基亚Lumia 925。我认为硬复位解决不了什么问题。
HttpBaseProtocolFilter protolFilter = new HttpBaseProtocolFilter();
protolFilter.ClientCertificate = certs[0] //from previous step
HttpClient client = new HttpClient(protolFilter)