Sujith S Nair
Sujith S Nair

Reputation: 738

First data api certificate creation error in asp.net

I have downloaded the permission file ("1909642928.pem") from the first data website, and put it into the solution folder. While trying to create a certificate file for the application from the permission file ("1909642928.pem") downloaded from first data website, I am getting an error:

The system cannot find the file specified.

CryptographicException:

at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
at System.Security.Cryptography.X509Certificates.X509Utils._QueryCertFileType(String fileName)
at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)
at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName)   at System.Security.Cryptography.X509Certificates.X509Certificate.CreateFromCertFile(String filename)
at WebApplication3._Default.Page_Load(Object sender, EventArgs e) in e:\MY_References\TestApps\App\App\Default.aspx.cs:line 20
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)     
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I am getting error form the following line:

FDGGWSApiOrderService OrderService = new FDGGWSApiOrderService();

OrderService.Url = @"https://ws.merchanttest.firstdataglobalgateway.com/fdggwsapi/services/order.wsdl";
OrderService.ClientCertificates.Add(X509Certificate.CreateFromCertFile>(("xxx.pem")));

Please assist me if I have to do anything more to create certificate from the permission file.

Upvotes: 7

Views: 586

Answers (2)

truemedia
truemedia

Reputation: 1062

Check the Security permissions on the file. If the webserver user is not able to read it, it will appear as not found.

Upvotes: 1

walter
walter

Reputation: 547

Maybe try using Server.MapPath("~/filename") to locate the file

Upvotes: 0

Related Questions