Solved

NO Certificate was found HttpWebRequest

Posted on 2004-08-05
4
455 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Align Buttons next to each other 2 25
SQL best practice question 3 36
Error in page 3 46
Show/Hide ASP.NET controls with JQuery best practices 3 21
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…
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.…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

863 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

19 Experts available now in Live!

Get 1:1 Help Now