【发布时间】:2014-04-14 15:43:09
【问题描述】:
我正在尝试从 CF.NET 中的文件加载 x509 证书。我正在尝试加载的证书can be downloaded here(它是 GoDaddy 根证书)。
我的代码如下所示:
byte[] bytes = null;
using (var certFile = new FileStream("\\gdroot-g2.crt", FileMode.Open, FileAccess.Read))
using (var br = new BinaryReader(certFile))
{
bytes = new byte[(int)certFile.Length];
br.Read(bytes, 0, bytes.Length);
}
//This line throws the error.
var cert = new X509Certificate2(bytes);
当我尝试加载证书时,我收到以下错误:
创建证书对象失败。传入的数据是 不正确或不受 .NET Compact Framework 支持。 .NET 紧凑型 框架不支持读取 pfx 文件。
我已验证我使用的 .CRT 文件是 Base-64 编码的。另外 - 当我在桌面上运行相同的代码(使用我们构建的移动模拟器)时,它会成功解析证书。
我在这里缺少一些基本的东西吗?
【问题讨论】:
-
什么版本的CF?
标签: compact-framework x509certificate