Can't Load Digital Certificate File using X509Certificate2

Discussion in 'ASP.NET / ASP.NET Core' started by Joe Francis, May 19, 2015.

  1. I am trying to load a digital certificate by putting the certificate on the site. I verified it is there. I then get the path to the cert with the MapPath call, which resolves to file name E:\web\joefrancis1\htdocs\myapp\new-p12-certificate.p12

    Server.MapPath("new-p12-certificate.p12");

    When I try to load the certicicate with the line of code below...

    cert = new X509Certificate2(certAndKeyFilename, certAndKeyPassword);

    ... I get the error "The system cannot find the file specified"
     
  2. FrankC

    FrankC DiscountASP.NET Staff

    This won't work on the server because this method requires the ASPNET user to load a user profile. Our IIS setup does not load user profile and thus will not work.

    To work around this, we can install your certificate to the server's machine store and you can modify the code to access the cert from the LocalMachine store

    See https://support.microsoft.com/en-us/kb/948154
     
    mjp likes this.
  3. OK. How can I request that? Is there perhaps a form to do so?
     
  4. mjp

    mjp

Share This Page