WebRequest to https!

S

Sudha

I want to create a POST Https webrequest .
Do i need to encrypt??
what all i need to encrypt?
how do i do that?
 
S

Sudha

ok i have basically written an exe which can be used to post some xml files
to both http and https sites.It works very fine for http sites.But it
doesn't work for https site.
Do i need to do anything extra for posting .I use the WebClient class.A
snippet of the code is as below:
WebClient wc = new WebClient();

wc.Headers.Add("Content-Type","application/octet-stream");

netCred = new NetworkCredential(uid,pwd);

wc.Credentials = netCred;

byte[] byteArray = Encoding.ASCII.GetBytes(strXML);

postStream = wc.OpenWrite(textBox1.Text.Trim(),"POST");

postStream.Write(byteArray,0,byteArray.Length);

Rgds
 
T

TJO

I have a current thread discussing the same issue (Please Help with
HttpWebRequest problem). I bet he is getting the same error I get which is:

"The underlying connection was closed: Could not establish secure channel
for SSL/TLS."

Kevin Cunningham said:
You do not have to do anything special. The fact that your url begins with
"https:" will cause the framework to "kick in" encryption. What type of
exception are you getting?

--
Kevin Cunningham
Software Architects


Sudha said:
ok i have basically written an exe which can be used to post some xml files
to both http and https sites.It works very fine for http sites.But it
doesn't work for https site.
Do i need to do anything extra for posting .I use the WebClient class.A
snippet of the code is as below:
WebClient wc = new WebClient();

wc.Headers.Add("Content-Type","application/octet-stream");

netCred = new NetworkCredential(uid,pwd);

wc.Credentials = netCred;

byte[] byteArray = Encoding.ASCII.GetBytes(strXML);

postStream = wc.OpenWrite(textBox1.Text.Trim(),"POST");

postStream.Write(byteArray,0,byteArray.Length);

Rgds


Sreejumon said:
Hi Sudha,

No need to encrypt the request. In order to use the HTTPS u ahev to
configure the SSL in your IIS. You ahve to use the deigital
certificates
to
configure the SSL. Then then encryption will be taken care by the browser
and web server.

--
Let me know if you need further help

Regards
Sreejumon[MVP]
DOTNET makes IT happen

I want to create a POST Https webrequest .
Do i need to encrypt??
what all i need to encrypt?
how do i do that?
 
J

Joerg Jooss

"Sudha" spoke:
I get the following error:
The underlying connection was closed.Could not establish trust
relationship with the remote server.
What settings should i have for the secured site directory.

It seems that site's certificate is rejected by the .NET framework's
default CertificatePolicy. Check out
http://msdn.microsoft.com/library/default.asp?url=/library/en-
us/cpref/html/frlrfSystemNetServicePointManagerClassCertificatePolicyTop
ic.asp

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

Top