473,473 Members | 2,031 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to send HTTPS-Post request using C# application

Hi,

I am trying to access a servlet hosted on Tomcat server using HTTPS
Post protocol. I am getting the exception:
"The underlying connection was closed: Could not establish trust
relationship with remote server".

Below is the code snippet. The same worked fine for HTTP POST. Then
when I configured the Tomcat server ffor HTTPS, and modified the code
by just changing the protocol from http to https. What more is to be
done for HTTPS??
I am not sure where is the gap.

Any help/url is highly appreciated.

------------------------------------------------------------------------------------------------------------------------
string str = "TEST DATA";
string uri =
"https://127.0.0.1:8443/MYLOGINPAGE/AMCWEBLOGINGATEWAY?LOGINID=guest&PASSWD=passwd12";
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(uri);request.KeepAlive = false;
request.ProtocolVersion=HttpVersion.Version10;
request.Method = "POST";

byte[] postBytes = Encoding.ASCII.GetBytes(str);
request.ContentType = "text";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();

HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Console.WriteLine(new
StreamReader(response.GetResponseStream()).ReadToE nd());
Console.WriteLine("Headers:");
Console.WriteLine(response.Headers.ToString());

------------------------------------------------------------------------------------------------------------------------

Nov 11 '06 #1
2 27112
This article could help: http://support.microsoft.com/kb/823177/en-us

"Arti" <ar********@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hi,

I am trying to access a servlet hosted on Tomcat server using HTTPS
Post protocol. I am getting the exception:
"The underlying connection was closed: Could not establish trust
relationship with remote server".

Below is the code snippet. The same worked fine for HTTP POST. Then
when I configured the Tomcat server ffor HTTPS, and modified the code
by just changing the protocol from http to https. What more is to be
done for HTTPS??
I am not sure where is the gap.

Any help/url is highly appreciated.

------------------------------------------------------------------------------------------------------------------------
string str = "TEST DATA";
string uri =
"https://127.0.0.1:8443/MYLOGINPAGE/AMCWEBLOGINGATEWAY?LOGINID=guest&PASSWD=passwd12";
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(uri);request.KeepAlive = false;
request.ProtocolVersion=HttpVersion.Version10;
request.Method = "POST";

byte[] postBytes = Encoding.ASCII.GetBytes(str);
request.ContentType = "text";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();

HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Console.WriteLine(new
StreamReader(response.GetResponseStream()).ReadToE nd());
Console.WriteLine("Headers:");
Console.WriteLine(response.Headers.ToString());

------------------------------------------------------------------------------------------------------------------------

Nov 12 '06 #2
Hi,

In my case the servlet is hosted on APACHE TOMCAT server. So how do I
go about it.

Thanks,
Arti

Nov 13 '06 #3

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

Similar topics

11
by: Google Mike | last post by:
I've got RH9 Linux with default PHP. Is there a way to send email on Linux to an Exchange Server from PHP and/or other tools when there is *NOT* SMTP access? Has anyone figured out a way to...
1
by: Josip Krapac | last post by:
Hello, I've got this situation: Servlet accessed by https (ie. https://host.domain/SecureServlet) starts a session (HttpSession session = req.getSession(true)), sets some session attributes...
1
by: Hasan D | last post by:
I'm new on this httplib and urllib. Actually I dont know what should i use. I want to fill the form in a "https" page , and return the result . I write a test code but always gives errors. I cant...
1
by: Kenneth Keeley | last post by:
Hi I wish to have a web site that has most of the pages as normal HTTP pages but has some areas that use HTTPS. I want to have it that if a user selects a link to a HTTPS page that they go there...
3
by: zn | last post by:
This is a beginner question. I need to create a page that is encrypted by SSL. The web server is already serving SSL encrypted web pages with "https" before the link. Do I need to do anything other...
0
by: Dima | last post by:
This is the beginner question. I installed j2ee on workstation, and I need transfer file from my server to outside of company (to another server). I need to use https. There is any way I can do it...
1
by: john_aspinall | last post by:
Hi, I want to send an email form on an ASP page and make it secure/ encrypted when sending it to the recipient. Does anyone know how I might easily achieve this - or should I be going through...
0
by: marcello lussana | last post by:
Hi, I'm trying to send some xml data to a WSDL server. Here's my code: xmldata = "<oesystem<user login=\"nekhem\" password=\"one5076\" tpoa=\"\"<message id=\"1\"<textTest di messaggio 1...
6
by: aRTx | last post by:
I can't see a class, but i know i can send arguments see: https://myaccount.smsdiscount.com/clx/sendsms.php?username=xxxxxxxxxx&password=xxxxxxxxxx&from=xxxxxxxxxx&to=xxxxxxxxxx&text=xxxxxxxxxx ...
0
by: vagueante | last post by:
Hi, I have to connect to a webservice, and the data i have is: WSDL XML sample file (which is what i have to send to the webservice and with credentials, user and password tags). XSD file My...
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...
1
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...
0
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...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.