Solved

NO Certificate was found HttpWebRequest

Posted on 2004-08-05
4
452 Views
Last Modified: 2012-08-14
I'm using HttpWebRequest and x509Certificate class to Post to another website in my server to check if it sees my client certificate:

in the response I'm getting 'No certificate was found' from the other page.

I have the client cert intalled in the LocalMachine\Personal Store. Let me know what other details you need


CODE FROM Client sending the cert:
X509Certificate cert = X509Certificate.CreateFromCertFile(@"QBClientCertDER2.cer");
              HttpWebRequest wr = (HttpWebRequest) WebRequest.Create(CheckCert.aspx);
            wr.ClientCertificates.Add(cert);                  
              wr.Method = "POST";
              wr.KeepAlive = false;
              wr.ContentType = "application/x-qbxml";
              wr.ContentLength = XMLRequest.Length;
            
              // send xml data
              StreamWriter SendStream;
            SendStream = new StreamWriter(wr.GetRequestStream());
              //SendStream.Write(byteArray,0,byteArray.Length);
            SendStream.Write(XMLRequest);
            SendStream.Flush();
              SendStream.Close();
              HttpWebResponse WebResp = (HttpWebResponse) wr.GetResponse();
              string res = "";

            
                  using (StreamReader sr = new StreamReader(WebResp.GetResponseStream()) )
                  {

                      res = sr.ReadToEnd();

                      sr.Close();

                  }

                        Output.Text = res.ToString();
                  Output.Text += cert.GetName();
                  WebResp.Close();

              }

              catch(Exception err)

              {

                  Response.Write(err.ToString() + "<br>");
             Response.Write(XMLRequest.ToString());

              }

CODE Checking the cert (CheckCert.aspx):
      Dim cs As HttpClientCertificate = Request.ClientCertificate
         If cs.IsPresent Then
             'Get the Organization (O) field from the Subject section.
             Response.Write("Cert subject: " & cs.Get("Subject O"))
         Else
             Response.Write("No certificate was found.")
         End If
0
Comment
Question by:vinny45
  • 2
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
AerosSaga earned 500 total points
Comment Utility
This will explain what steps you need to take:

http://support.microsoft.com/default.aspx?scid=kb;en-us;320602

http://www.wilsonmar.com/1certs.htm

Regards,

Aeros
0
 

Author Comment

by:vinny45
Comment Utility
I'm not sure if i wan't to sign an xml object.

Also, i think I've intalled the client cert in  local_machine\personal
and the accompanying CA in the Root folder

0
 
LVL 17

Expert Comment

by:AerosSaga
Comment Utility
your not signing the xml object your signing the request.
0
 

Author Comment

by:vinny45
Comment Utility
yes, HttpWebRequest.ClientCertificate.Add.....

any ideas. I think something is preventing HTTPWebrequest from sending the cert to the remote server.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now