Need to call a web service using certificates!

J

jens Jensen

Hello,

I'm developing a solution on my win xp and need to connect to webservice
that just uses xml over http.
I'm provided with a pair of certificates.

My code start with the following:

store.Certificates.Find(

X509FindType.FindBySubjectDistinguishedName,

"CN=Mario, CN=Szpuszta", false);



From the pair of certificates, how do idenfy CN , and CN?



Maybe i just need basic understand of x509 certs.





Many thanks in advance:



Here the entire code;



// Read the certificate from the store

X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

store.Open(OpenFlags.ReadOnly);

try

{

// Try to find the certificate

// based on its common name

X509Certificate2Collection Results =

store.Certificates.Find(

X509FindType.FindBySubjectDistinguishedName,

"CN=Mario, CN=Szpuszta", false);

if (Results.Count == 0)

throw new Exception("Unable to find certificate!");

else

{

Certificate = Results[0];

HttpWebRequest req =
(HttpWebRequest)HttpWebRequest.Create(ConfigurationManager.AppSettings["URI"]);

req.ClientCertificates.Add(Certificate);

req.Proxy = new
System.Net.WebProxy(ConfigurationManager.AppSettings["ProxyString"], true);

req.ContentType = "application/x-www-form-urlencoded";

req.Method = "POST";

byte[] bytes = System.Text.Encoding.ASCII.GetBytes(message);

req.ContentLength = bytes.Length;

System.Net.WebResponse resp = req.GetResponse();

// if (req == null) return null;

System.IO.StreamReader sr = new
System.IO.StreamReader(resp.GetResponseStream());

// return ;

}

}

catch

{

//Error logging



}

finally

{

store.Close();

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top