我在 Windows Mobile 6 中工作,并且希望在与 Apache 网络服务器通信时进行客户端身份验证。我的本地证书存储中有一个证书,它应该相当简单:
X509Store myStore = new X509Store("MY", StoreLocation.CurrentUser);
myStore.Open(OpenFlags.ReadOnly);
X509Certificate2Collection certificates = myStore.Certificates;
X509Certificate2 clientcertificate;
foreach (X509Certificate 2certificate in certificates) {
clientcertificate = certificate; //omitted code to validate certificate
}
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(webPage);
req.AllowWriteStreamBuffering = true;
req.AllowAutoRedirect = false;
req.Method = "POST";
req.ContentType = "text/xml";
req.Accept = "text/xml";
req.ClientCertificates.Add(clientcertificate);
Stream stream = req.GetRequestStream();
stream.Write(buffer, 0, buffer.Length);
stream.Close();
只要我删除“req.ClientCertificates.Add(clientcertificate)”行,此代码段就可以工作。
插入后,我会收到“无法为 SSL/TLS 建立安全通道”。令人发指的是,当我在常规 .Net 框架中使用这个确切的代码时,它完美地传输了证书。
有谁知道这在 Compact Framework 中是否可行?如果我无法提供 X509Certificate 进行客户端身份验证,我应该采取哪些其他方式来确保身份验证正确(我应该有权访问 CAPI 或其他 Microsoft 加密模块)
谢谢。