[Mono-list] HttpWebRequest HTTPS problem -WebExceptionStatus.SendFailure
Gert Driesen
gert.driesen at telenet.be
Wed Jan 30 09:14:58 EST 2008
Hi Timothy,
I already submitted a bug report for this:
https://bugzilla.novell.com/show_bug.cgi?id=346635
Gert
----- Original Message -----
From: "Timothy Parez" <timothyparez at gmail.com>
To: <mono-list at lists.ximian.com>
Sent: Wednesday, January 30, 2008 3:10 PM
Subject: Re: [Mono-list] HttpWebRequest HTTPS problem -WebExceptionStatus.SendFailure
> No,
>
> InnerException == null.
>
> The exception is thrown when trying to write to the request stream.
>
> 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/67e5fb4e._4.cs:278
>
> Timothy.
>
>
>
> On Jan 30, 2008 2:10 PM, Sebastien Pouliot <sebastien.pouliot at gmail.com>
> wrote:
>
>> Hey,
>>
>> On Tue, 2008-01-29 at 23:31 +0100, Timothy Parez wrote:
>> > 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?
>>
>> Is there an inner exception ? It's possible that the original exception
>> got wrapped somewhere.
>>
>> >
>> >
>> >
>> >
>> > 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.
>> > >
>> >
>> > _______________________________________________
>> > Mono-list maillist - Mono-list at lists.ximian.com
>> > http://lists.ximian.com/mailman/listinfo/mono-list
>>
>>
>
--------------------------------------------------------------------------------
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
More information about the Mono-list
mailing list