|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to send HTTPS-Post request using C# application??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()).ReadToEnd()); Console.WriteLine("Headers:"); Console.WriteLine(response.Headers.ToString()); ------------------------------------------------------------------------------------------------------------------ Arti wrote:
> Hi, Is the server certificate good? i.e. when you browse to the site with IE, > > 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. does it pop up any warning dialogs like wrong server name, cert expired, untrusted root, etc? If so, then you need to read this article: http://support.microsoft.com/kb/823177/en-us -cd |
|||||||||||||||||||||||