发送带有 X509 证书的 http post 时设备未准备好

Device not ready when sending http post with X509 Certificate

我有一个 windows 应用程序,它使 HTTP post 发送和接收一些 XML。在 Windows PC 上它可以工作,但自从将其移至测试服务器 (Windows 2008 r2) 后,我在加载证书.

错误有点模糊,显然搜索是一些非常模糊的结果。有人遇到过这个吗?代码在 Dim Certificate 处中断....

证书已安装并可导出。不胜感激。

Dim SendPropertyUri As String = "http://post.url"
Dim request As HttpWebRequest
Dim byteData() As Byte
Dim postStream As Stream = Nothing
request = DirectCast(WebRequest.Create(SendPropertyUri), HttpWebRequest)
Dim certificate As New X509Certificate("D:\Processor\certificates\mycert.p12", "password")
request.ClientCertificates.Add(certificate)
request.Method = "POST"
request.ContentType = "application/xml"
request.Accept = "application/xml"
byteData = UTF8Encoding.UTF8.GetBytes(foo.OuterXml)
request.ContentLength = byteData.Length
postStream = request.GetRequestStream()
postStream.Write(byteData, 0, byteData.Length)
postStream.Close()

经过一些研究后,通过安装 IIS6 兼容组件解决了这个问题。不确定到底是什么导致了问题,但在安装 IIS6 管理控制台后它运行正常。

只是回答,因为错误是一个模糊的错误,所以可能会帮助其他人或给他们一个起点。