473,658 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Web Exception' occurred in
system.dll

Additional information: The underlying connection was closed: Unable
to connect to the remote server.
This exception is thrown when the GetRequestStrea m() 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 .CreateFromCert File("c:\\Certi ficates\\client _cert.cer");
WebRequest request = GetWebRequest(n ew
Uri("https://client_web/methodserver.ph p"));

// Works
//X509Certificate cert =
X509Certificate .CreateFromCert File("c:\\Certi ficates\\verisi gn_cert.cer");
//WebRequest request = GetWebRequest(n ew
Uri("https://server.com/testpage.aspx") );
request.Content Type = "text/xml";
request.Method = "POST";

HttpWebRequest httpRequest = (HttpWebRequest )request;
httpRequest.Use rAgent = "Exel Test";
httpRequest.Hea ders = new WebHeaderCollec tion();
httpRequest.Cli entCertificates .Add(cert);

request = (WebRequest)htt pRequest;

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

WebResponse resp = GetWebResponse( request);
Stream respStream = resp.GetRespons eStream();

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

string certInfo = tr.ReadToEnd();

System.Diagnost ics.Debug.Write Line(certInfo);
}
Nov 18 '05 #1
1 2930
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*********@hot mail.com (Krishna) wrote in message news:<76******* *************** ****@posting.go ogle.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.Web Exception' occurred in
system.dll

Additional information: The underlying connection was closed: Unable
to connect to the remote server.
This exception is thrown when the GetRequestStrea m() 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 .CreateFromCert File("c:\\Certi ficates\\client _cert.cer");
WebRequest request = GetWebRequest(n ew
Uri("https://client_web/methodserver.ph p"));

// Works
//X509Certificate cert =
X509Certificate .CreateFromCert File("c:\\Certi ficates\\verisi gn_cert.cer");
//WebRequest request = GetWebRequest(n ew
Uri("https://server.com/testpage.aspx") );
request.Content Type = "text/xml";
request.Method = "POST";

HttpWebRequest httpRequest = (HttpWebRequest )request;
httpRequest.Use rAgent = "Exel Test";
httpRequest.Hea ders = new WebHeaderCollec tion();
httpRequest.Cli entCertificates .Add(cert);

request = (WebRequest)htt pRequest;

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

WebResponse resp = GetWebResponse( request);
Stream respStream = resp.GetRespons eStream();

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

string certInfo = tr.ReadToEnd();

System.Diagnost ics.Debug.Write Line(certInfo);
}

Nov 18 '05 #2

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

Similar topics

1
2581
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 "conflicting header files," but I don't know what to do about conflicting header files, or where I would find them, and once I found them, which ones to remove. I have compiled MySQL 4.1 and installed into /usr/local/mysql, but since have moved to a Fink...
4
5198
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 Server, now I need to connect to our Oracle Financials running on HP-UX. The Oracle DBA set me up as a user and installed the Oracle client on my box and I have the tnsnames file, but I still can't establish a connection to the database from my...
1
1474
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. But I don't want any interaction from the user...I don't want them to have to enter a username and password. So I believe part of the solution is to use certificates...Many-to-one...Right?
4
6049
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 authenticated with the mainframe and if its ok, then the application proceeds using the generic application id. We are not able to track the user in the DB2 on Mainframe. Is there anyway I can pass the end userid along with the generic userid, so I...
0
334
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 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.
0
1201
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 .NET Webservice to test the same. I had created the PFX certificates and then used it across different platforms. All these certificates were working fine on the microsoft platforms. But when i switched my environment to AS400 I was facing...
5
4442
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 certificate, since it derives System.Web.Services.WebService class, and it's Context.Request.ClientCertificate is a single HttpClientCertificate object, is there a way to receive all the client certificates that is sent in the request? or does IIS...
0
1009
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 Services Enhancements (WSE) 2.0 but it seems it does only work with local stores. I also need to generate client certificates thrue this CA. I can use the "old" ASP pages, but I appreciate .NET solution. I need it in two ways ... One as usual...
0
1590
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 am not in control of this server or web service). I can create a web reference using VS2005 with the https URL of the WSDL file. When I try sending the data I receive the below error: "Unable to connect to the remote server" I added the...
0
8330
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8746
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8523
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8626
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.