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();
}
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();
}