Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Connect to web site using SSL & Client Certificates

Reply
Thread Tools

Connect to web site using SSL & Client Certificates

 
 
Krishna
Guest
Posts: n/a
 
      05-17-2004
Well, I got it working when running against my test server (IIS5 W2K
svr, I will attach a sample of the code at the bottom of this
message), but now I'm connecting to our client (Apache) I'm getting
the following error:

An unhandled exception of type 'System.Net.WebException' occurred in
system.dll

Additional information: The underlying connection was closed: Unable
to connect to the remote server.


This exception is thrown when the GetRequestStream() method is
called and I am using a client cert that was issued to us from their
internal CA (they are using OpenSSL).

Any help'd be much appreciated!

Regards,kg.


public void Connect()
{
// Doesn't work
X509Certificate cert =
X509Certificate.CreateFromCertFile("c:\\Certificat es\\client_cert.cer");
WebRequest request = GetWebRequest(new
Uri("https://client_web/methodserver.php"));

// Works
//X509Certificate cert =
X509Certificate.CreateFromCertFile("c:\\Certificat es\\verisign_cert.cer");
//WebRequest request = GetWebRequest(new
Uri("https://server.com/testpage.aspx"));


request.ContentType = "text/xml";
request.Method = "POST";

HttpWebRequest httpRequest = (HttpWebRequest)request;
httpRequest.UserAgent = "Exel Test";
httpRequest.Headers = new WebHeaderCollection();
httpRequest.ClientCertificates.Add(cert);

request = (WebRequest)httpRequest;

// This is where it breaks...
Stream reqStream = request.GetRequestStream();
reqStream.Close();

WebResponse resp = GetWebResponse(request);
Stream respStream = resp.GetResponseStream();

TextReader tr = new StreamReader(respStream, new UTF8Encoding(), true,
4096);

string certInfo = tr.ReadToEnd();

System.Diagnostics.Debug.WriteLine(certInfo);
}
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python xmlrpc client with ssl client certificates and standard modules News123 Python 9 02-15-2012 01:04 PM
Ssl.com now carries all the major brands of SSL certificates jenny General Computer Support 0 11-30-2006 09:18 AM
Are SSL certificates and x.509 certificates the same? n33470 ASP .Net Web Services 0 12-14-2005 03:30 PM
SSL / Web Service requring client certificates. No certificate server side...? Matthew ASP .Net Security 0 11-02-2004 11:44 AM
Connect to web site using SSL & Client Certificates Krishna ASP .Net 1 05-19-2004 02:03 AM



Advertisments