HTTPS and WebRequest

T

Tony Guidici

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.OutboundURL);

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.
 
R

Rajesh.V

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.
 
J

Joerg Jooss

Rajesh.V said:
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top