mardi 2 juin 2015

AppHarbor - System.Security.Cryptography.CryptographicException: The system cannot find the file specified

Running into a strange problem with my MVC solution hosted on AppHarbor. Locally it runs perfectly fine, but i'm getting an exception thrown to me when on production (appharbor).

Code from stack trace:

string keyFilePath = HttpContext.Current.Server.MapPath("~/key.p12");
string serviceAccountEmail = "my-email-here@developer.gserviceaccount.com";
var certificate = new X509Certificate2(keyFilePath, "notasecret", X509KeyStorageFlags.Exportable);

ServiceAccountCredential credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmail)
   {
      Scopes = new[] { "http://ift.tt/1jB3mSx" }
   }.FromCertificate(certificate));

Further jumping into this problem, the problem is from the first line of my code:

string keyFilePath = HttpContext.Current.Server.MapPath("~/key.p12");

For some reason, my server cannot find the file specifed (yes, it is there, I checked). Any thoughts on how to reference the file?

Aucun commentaire:

Enregistrer un commentaire