[Mono-list] HttpWebRequest HTTPS problem - WebExceptionStatus.SendFailure

Timothy Parez timothyparez at gmail.com
Tue Jan 29 17:31:08 EST 2008


Hi,

Someone pointed me to this document:
http://www.mono-project.com/UsingTrustedRootsRespectfully


But when I use something similar to the code on that page just to test:
catch (WebException we) {
			if (we.Status != WebExceptionStatus.TrustFailure)
				throw;
			Console.WriteLine ("You do not trust the people who " +
				"issued the certificate being used by '{0}'." +
				" Please see the application help file on " +
				"the 'trust certificate' subject to learn " +
				"about how this can be fixed.", args [0]);

It simply throws this again:

error writing request.

Description: Error processing request.

Error Message: HTTP 500. System.Net.WebException: Error writing request.

Stack Trace:

System.Net.WebException: Error writing request.
   at System.Net.WebConnectionStream.WriteRequest () [0x00169] in /usr/ 
src/mono-1.2.6/mcs/class/System/System.Net/WebConnectionStream.cs:563
   at System.Net.WebConnectionStream.Close () [0x000e0] in /usr/src/ 
mono-1.2.6/mcs/class/System/System.Net/WebConnectionStream.cs:613
   at GoogleDocumentManager.Authenticate () [0x000b5] in /tmp/www-data- 
temp-aspnet-0/b9f31472/70040e1b._4.cs:279

The actual status is WebExceptionStatus.SendFailure.

Any ideas?



On 29 Jan 2008, at 12:34, Timothy Parez wrote:

> Hi,
>
> I have the following code as part of an ASP.NET application.
> Hosted on Ubuntu with Mono 1.2.6 Apache2/mod_mono:
>
>     private string Authenticate(string Username, string Password)
>     {
>             //Create a web request for the Google ClientLogin service
>             HttpWebRequest authRequest =  
> (HttpWebRequest)HttpWebRequest
> .Create("https://www.google.com/accounts/ClientLogin");
>             authRequest.KeepAlive = false;
>             authRequest.ContentType = "application/x-www-form- 
> urlencoded";
>             authRequest.Method = "POST";
>
>             //Build the POST data
>             StringBuilder postBuilder = new StringBuilder();
>             postBuilder.AppendFormat("accountType={0}",  
> GOOGLE_ACCOUNT_TYPE);
>             postBuilder.AppendFormat("&Email={0}", Username);
>             postBuilder.AppendFormat("&Passwd={0}", Password);
>             postBuilder.AppendFormat("&service={0}", GOOGLE_SERVICE);
>             postBuilder.AppendFormat("&source={0}", GOOGLE_SOURCE);
>
>             //Convert the POST data to a byte[]
>             byte[] data =  
> ASCIIEncoding.ASCII.GetBytes(postBuilder.ToString());
>             authRequest.ContentLength = data.Length;
>
>             //Get the request stream and POST the data
>             Stream requestStream = authRequest.GetRequestStream();
>             requestStream.Write(data, 0, data.Length);
>
>             requestStream.Close();
>
>             //Get the response
>             HttpWebResponse authResponse =  
> (HttpWebResponse)authRequest.GetResponse();
>             Stream responseStream = authResponse.GetResponseStream();
>             StreamReader responseReader = new  
> StreamReader(responseStream);
>
>             string response = responseReader.ReadToEnd();
>
>             //Always clean up after yourself
>             responseReader.Close();
>             responseStream.Close();
>
>             //All we care about is the Auth value
>             if (response.Contains("Auth"))
>             {
>                 int index = response.LastIndexOf("=") + 1;
>                 string auth = response.Substring(index,  
> response.Length - index);
>                 return auth;
>             }
>             else
>             {
>                 throw new Exception(response);
>                 //return "";
>             }
>       }
>
> When this code is executed I get the following exception:
>
> System.Net.WebException: Error writing request. at  
> System.Net.WebConnectionStream.WriteRequest () [0x00169] in /usr/src/ 
> mono-1.2.6/mcs/class/System/System.Net/WebConnectionStream.cs:563 at  
> System.Net.WebConnectionStream.Close () [0x000e0] in /usr/src/ 
> mono-1.2.6/mcs/class/System/System.Net/WebConnectionStream.cs:613 at  
> GoogleDocumentManager.Authenticate () [0x000d8] in /tmp/www-data- 
> temp-aspnet-0/b9f31472/693a96d7._4.cs:286
>
>
> This works fine on Windows/IIS/ASP.NET
> Any ideas what might be causing it?
>
> Thank you.
>
> Timothy.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20080129/f9c1445c/attachment-0001.html 


More information about the Mono-list mailing list