Solved

NO Certificate was found HttpWebRequest

Posted on 2004-08-05
4
458 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
ID: 11725262
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
ID: 11731025
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
ID: 11734616
your not signing the xml object your signing the request.
0
 

Author Comment

by:vinny45
ID: 11737682
yes, HttpWebRequest.ClientCertificate.Add.....

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

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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