语境
我有一个pfx证书文件。我可以X509Certificate2
使用以下代码将其成功加载到类中:
var path = "mycert.pfx"
var password = "mypassword";
var certificate = new X509Certificate2(path, password);
由于某些原因,我想使用.pem格式而不是二进制格式。因此,我已使用以下OpenSSL命令将“ mycert.pfx”转换为“ mycert.pem”:
pkcs12 -in mycert.pfx -out mycert.pem -nodes
问题
如何以与成功加载mycert.pfx类似的方式加载转换后的mycert.pem?下面的代码给我一个CryptographicException,说“找不到请求的对象”。(注意:这不是关于找不到文件的io例外)
var path = "mycert.pem"
var password = "mypassword";
var certificate = new X509Certificate2(path, password);
Windows不支持PEM(Base64)格式的PKCS#12。您只能使用二进制编码的PKCS#12文件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句