Need to call a web service using certificates!

Discussion in 'ASP .Net Web Services' started by jens Jensen, Mar 21, 2006.

  1. jens Jensen

    jens Jensen Guest

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

    }
    jens Jensen, Mar 21, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. bs
    Replies:
    0
    Views:
    454
  2. Not Me
    Replies:
    1
    Views:
    3,172
    Not Me
    Jun 5, 2007
  3. LosManos
    Replies:
    2
    Views:
    624
    Peter Foot [MVP]
    Jan 28, 2006
  4. Fabio Franzini via .NET 247

    Error on call web service from asp.net whit certificates

    Fabio Franzini via .NET 247, Mar 10, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    174
    Fabio Franzini via .NET 247
    Mar 10, 2005
  5. n33470

    Are SSL certificates and x.509 certificates the same?

    n33470, Dec 14, 2005, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    175
    n33470
    Dec 14, 2005
Loading...

Share This Page