473,395 Members | 1,863 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,395 software developers and data experts.

HTTPS and WebRequest

I have been attempting to send an XML post to a ASPX page I created as a
listener. On our Windows Server 2003 Web Edition server, I installed a test
certificate from Thawte and can hit the page just fine from the browser.
However, when I attempt to use the WebRequest object to post to the page, I
get the folowing error:

"The underlying connection was closed: Could not establish trust
relationship with remote server."

I used the following code:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(client.OutboundU RL);

req.Method = "POST";

req.ContentType = "text/xml";

req.PreAuthenticate = true;

req.Credentials = new NetworkCredential(client.WebSendID,
client.WebSendPwd);

Stream xmlSend;

try

{

xmlSend = req.GetRequestStream();

}

catch(Exception ex)

{

Debug.WriteLine("Error getting stream to outbound resource.");

throw ex;

}
The code works fine if I use HTTP instead of HTTPS. I have searched Google,
MSDN, and any other source I can find, with some answers that haven;t worked
so far.

Can anyone help me?

Thanks,

Tony Guidici

President, Sr. Consultant
Vero Solutions, Inc.
Nov 17 '05 #1
2 4500
You would have to do this.

1. export the certificate to x.509 format and place it on the webserver.
2. Add the certificate to the httprequest.certificate collection.
3. Install the certificate in the ie of the webserver.

Check with steps 1 and 2 only first. If not working do step 3 also.

"Tony Guidici" <ag******@att.net> wrote in message
news:_j*********************@bgtnsc05-news.ops.worldnet.att.net...
I have been attempting to send an XML post to a ASPX page I created as a
listener. On our Windows Server 2003 Web Edition server, I installed a test certificate from Thawte and can hit the page just fine from the browser.
However, when I attempt to use the WebRequest object to post to the page, I get the folowing error:

"The underlying connection was closed: Could not establish trust
relationship with remote server."

I used the following code:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(client.OutboundU RL);
req.Method = "POST";

req.ContentType = "text/xml";

req.PreAuthenticate = true;

req.Credentials = new NetworkCredential(client.WebSendID,
client.WebSendPwd);

Stream xmlSend;

try

{

xmlSend = req.GetRequestStream();

}

catch(Exception ex)

{

Debug.WriteLine("Error getting stream to outbound resource.");

throw ex;

}
The code works fine if I use HTTP instead of HTTPS. I have searched Google, MSDN, and any other source I can find, with some answers that haven;t worked so far.

Can anyone help me?

Thanks,

Tony Guidici

President, Sr. Consultant
Vero Solutions, Inc.

Nov 17 '05 #2
"Rajesh.V" wrote:
You would have to do this.

1. export the certificate to x.509 format and place it on the
webserver. 2. Add the certificate to the httprequest.certificate
collection. 3. Install the certificate in the ie of the webserver.


Depending on the certificate (and especially with this one), this is not
sufficient. He also needs to provide an appropriate ICertificatePolicy
that does not reject the server certificate, since the FCL's default
implementation will do that.

Cheers,
--
Joerg Jooss
jo*********@gmx.net
Nov 17 '05 #3

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

Similar topics

4
by: Drew | last post by:
I have been looking all over the web for an example of how to accomplish this. I am trying to download a comma seperated file from a https server. I can't establish the connection - the error reads...
5
by: mammothman42 | last post by:
Hi Sorry to be posting slabs of code, but i simply can't get this code to work. I continue to get error 405, method not allowed at req.GetRequestStream(). Can't for the life of me figure out...
3
by: Frank Schwarz | last post by:
Hello, we are implemting an application that uses a https connection for accessing a website. It is also possible to connect via http. With http every thing works fine. With https it is not...
5
by: MajorTom | last post by:
Hello group I have a winforms client application. The customer now wants to have access to information that is on a web page via https. We have all the necessary account and password, but the...
0
by: Christian F CLY | last post by:
Hello, I'm trying to connect a https server with an application. but i catch this error "The connection was closed. Unable to connect to the Remote server" I want to connect a secure...
2
by: Jonathan Wax | last post by:
Hi, I spent the last week looking for an answer to the following question: How can you upload an xml file to an HTTPS server with a specific certificate. Basically doing the same as this html...
2
by: Amoril | last post by:
I am currently developing an app that will post an XML file (1 to 100MB+ in size) to an outside vendor application via HTTPS Post (doing this in a vb.net windows app). The vendor will then at some...
7
by: Masahiro Ito | last post by:
I need to be login to several websites and download files that are https connections. I just tried IPWorks demo, but it does not seem to offer https. Does anyone know an https capable product,...
4
by: Nader Shahin | last post by:
I tried to develop an application to download a file from an Https server. My application was able to download a file from a regural Http server. I used a WebProxy and i passed the...
0
by: =?Utf-8?B?VGFoYQ==?= | last post by:
I am working on a C#.Net application that consumes a web service developped (by others) in Java. My application calls a web method to post a 64-bit binary file to the web service. The...
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.