Cryptography Class Problem

Discussion in 'ASP.NET 2.0' started by YongCool, Jul 15, 2006.

  1. > Hello,
    > I am currently developing a e-commerce site with paypal.
    > I finally got DoDirectPayment function working and I was able to get the fund from the sandbox account.
    > However, this only works on my local computer.
    > When I uploaded the files and ran it, it gave me the following error.
    >
    > Exception Details: System.Security.Cryptography<WBR>.CryptographicException: The system cannot find the file specified.
    >
    > And here is the related part of the code.
    >
    > String certlocation = Server.MapPath("Certs/sandbox_cert.p12");
    > FileStream fs = File.Open(certlocation, FileMode.Open, FileAccess.Read);
    > byte[] buffer = new byte[fs.Length];
    > int count = fs.Read(buffer, 0, buffer.Length);
    > fs.Close();
    >
    > X509Certificate2 cert = new X509Certificate2(buffer, "yongcool"); ====> I GET THE ERROR HERE.
    >
    > I checked the path and tried alternates several times but none of them worked.
    > Could you please help me with this??
    >
    > THANKS in advance
     
  2. I just found this thread.
    http://community.discountasp.net/default.aspx?f=5&amp;m=8905
    I realized that I installed the certificate that I got from the paypal on my local computer, using the mmc.
    Maybe you guys need to install the certificate on your end?
    Does it really cost 15 dollars?
    Please let me know as soon as possible.
    Thank you.
     
  3. Takeshi Eto

    Takeshi Eto DiscountASP.NET Staff

    Yes, there is a $15 service fee as it needs to be manually installed. Please contact our Technical Support department.

    Eric
    DiscountASP.NET
    http://www.DiscountASP.NET
     
  4. The Paypal certificate doesn't need to be installed on the web server if you're using ASP.NET 2.0. It can work with the PFX file directly.

    The CryptographicException error 'cannot find the file specified' is a known issue.

    As we understand it, when you create a new X509 certificate object, the key needs to be stored temporarily somewhere. By default, the User keystore is used, which is the site's ASPNET user keystore. DiscountASP does not provide a Windows profile for ASPNET users, so the User keystore doesn't exist. Therefore, you must configure it to use the Machine keystore instead.

    Modify your code so that the X509Certificate2 class is instantiated with a third argument, X509KeyStorageFlags.MachineKeySet.

    For example,
     

Share This Page