Solved

NO Certificate was found HttpWebRequest

Posted on 2004-08-05
4
465 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

691 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