473,387 Members | 1,512 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,387 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 2905
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.