The Azure portal will not let me add a Cer file. I found a post saying you can type the name in, you can only do this from the open dialogue and it does not work
So I am trying to convert the file using code I have placed in my Global.asax. I have copied the CER file into my temp directory off the root of C drive
Here is the code and Error I get :
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();
}