-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Description
I am trying to load a .p12 file into a X509Certificate2 object.
The code runs fine on my local machine.
Whenever, I run the following line on Azure, it crashes the asp.net process with a CGI error:
var certificate = new X509Certificate2(fileBytes, "notasecret", X509KeyStorageFlags.Exportable);
The following line does not crash:
var cert = new X509Certificate2();
Also, if the password is incorrect, the server gives a normal exception explaining that the password is incorrect:
var certificate = new X509Certificate2(fileBytes, "wrong");
I upgraded to 1.0.1 hoping it would solve the problem, but it occured on both 1.0.0 and 1.0.1.
So, to be clear:
- Only crashes on Azure App Site (with CGI error)
- Only happens when the cert file password is correct
Here is the full code:
```
var log = "";
var keyFileServerPath = _env.ContentRootPath + @"\GACert.p12";
log += "\r\n" + "Got File Path";
var cert = new X509Certificate2();
log += "\r\n" + "Created Empty Cert";
var fileExists = System.IO.File.Exists(keyFileServerPath);
log += "\r\n" + "File Exists? =" + fileExists;
var fileBytes = System.IO.File.ReadAllBytes(keyFileServerPath);
log += "\r\n" + "File Bytes.Length=" + fileBytes.Length;
//// WRONG PASSWORD - Causes a normal Exception (so password is OK)
//var certificate = new X509Certificate2(fileBytes, "wrong");
//log += "\r\n" + "Created Cert Using Bytes";
//// FAILED - CGI Error (Crashing the Asp.Net Process)
//var certificate = new X509Certificate2(fileBytes, "notasecret", X509KeyStorageFlags.Exportable);
//log += "\r\n" + "Created Cert Using Bytes";
Metadata
Metadata
Assignees
Labels
No labels