I am writing a program to submit xml files to a website using HTTPWebRequest. However, the following gives me an exception of "Cannot find the original signer": X509Certificate certificate = X509Certificate.CreateFromCertFile("myCert.p7b"); or X509Certificate2 certificate = new X509Certificate2("myCert.p7b");
This link shows a similar (maybe identical) question, but the answer is kind of too general for me. I am wondering if anyone could provide a step by step instruction for the solution.
Thanks.
X509Certificate certificate = X509Certificate.CreateFromCertFile("myCert.p7b");
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.foo.com/xmlService/versionX");
request.ClientCertificates.Add(certificate);
byte[] bytes;
bytes = System.Text.Encoding.ASCII.GetBytes("myFile.xml");
request.ContentType = "text/xml; encoding='utf-8'";
request.ContentLength = bytes.Length;
request.Method = "POST";
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
Stream responseStream = response.GetResponseStream();
string responseStr = new StreamReader(responseStream).ReadToEnd();
return responseStr;
}
return null;