Azure门户不允许我添加Cer文件。我发现一则讯息说您可以输入名称,您只能在公开对话中输入名称,但无法使用
因此,我尝试使用放置在Global.asax中的代码转换文件。我已将CER文件复制到C驱动器根目录下的临时目录中
这是代码和我得到的错误:
string file = @"C:\temp\SVRSecureG3.cer";
var cert = System.Security.Cryptography.X509Certificates.X509Certificate2.CreateFromCertFile(file);
// Error occurs on the line below, I get : {"Unable to cast object of type 'System.Security.Cryptography.X509Certificates.X509Certificate' to type 'System.Security.Cryptography.X509Certificates.X509Certificate2'."}
var bytes = ((System.Security.Cryptography.X509Certificates.X509Certificate2)cert).Export(System.Security.Cryptography.X509Certificates.X509ContentType.Pfx, "p");
var fs = File.Create(@"C:\temp\SVRSecureG3.pfx");
using (fs)
{
fs.Write(bytes, 0, bytes.Length);
fs.Flush();
}
我实际上只是建议将您的.cer转换为.pfx。使用OpenSSL可以做到这一点,我已经无数次地将证书上传到Azure。
下载
http://slproweb.com/products/Win32OpenSSL.html
用法
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句