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();
}
答案 0 :(得分:1)
我实际上只是建议将.cer转换为.pfx。使用OpenSSL执行此操作,我已多次将证书上载到Azure。
下载
http://slproweb.com/products/Win32OpenSSL.html
<强>用法强>