473,396 Members | 1,590 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Connect to web site using SSL & Client Certificates

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);
}
Nov 18 '05 #1
1 2906
Okey dokey, well only a little embarrassed! I didn't have the
private key for the Client Cert that our client gave us, therefor it
wasn't properly loaded in my Personal Cert store, therefor when the
connection was being negotiated it crashed... I got the full key
pair from them and voila!

Hope this helps anyone!

Krishna.

kr*********@hotmail.com (Krishna) wrote in message news:<76**************************@posting.google. com>...
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);
}

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Peter Nikolaidis | last post by:
Greetings, I am attempting to get MySQLdb 0.9.2 installed on Mac OS 10.2 with a Fink distribution of Python 2.2.2. I have seen only a few posts on the subject, some of them relate to...
4
by: Ellen K. | last post by:
Hi all, Being that so far I didn't get an answer to my below problem on the Oracle newsgroup, I figured it couldn't hurt to try here. While at my current job I've been working with mostly SQL...
1
by: Next | last post by:
Hello, I sure could use someone's help : ) I need to authenticate users and securely upload files from laptops on the internet ( not on the same domain as server ) to a server on my domain....
4
by: Wonderinguy | last post by:
Our websphere application uses a generic application userid to connect and query db2 on z/os via DB2 connect. The end user,logs in to the application using his regular userid, which is then...
0
by: Krishna | last post by:
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...
0
by: Ankur Tyagi via .NET 247 | last post by:
Hey, I have been trying to actually explore the various certificates available across all the platforms. I had started with Microsoft Certiying Authority of the microsoft. I had actually created a...
5
by: | last post by:
Hi all, HttpWebRequest, and SoapHttpClientProtocol both expose a ClientCertificates property, which can hold multiple client certificates, but on the service side, it can only receive one client...
0
by: George | last post by:
Hello, I need to communicate with Certification Authority (Windows 2003) to browse issued (or other groups) certificates thrue the .NET. Is it possible? Is there any solution? I have tried Web...
0
by: WatchoutMac | last post by:
I have a C# .NET client (2.0 Framework) that needs to connect to a java web service (built with Axis) and send some data for processing. The java web service is hosted on a secured Apache server ( I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.