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

Timothy Parez timothyparez at gmail.com
Tue Jan 29 18:07:27 EST 2008


I even tried this just in case:


certmgr --ssl https://www.google.com/accounts/ClientLogin
Mono Certificate Manager - version 1.2.6.0
Manage X.509 certificates and CRL from stores.
Copyright 2002, 2003 Motus Technologies. Copyright 2004-2007 Novell.  
BSD licensed.


  X.509 Certificate v3
    Issued from: C=US, O="VeriSign, Inc.", OU=Class 3 Public Primary  
Certification Authority
    Issued to:   C=ZA, O=Thawte Consulting (Pty) Ltd., CN=Thawte SGC CA
    Valid from:  5/13/2004 2:00:00 AM
    Valid until: 5/13/2014 1:59:59 AM
    *** WARNING: Certificate signature is INVALID ***
This certificate is already in the CA store.

  X.509 Certificate v3
    Issued from: C=ZA, O=Thawte Consulting (Pty) Ltd., CN=Thawte SGC CA
    Issued to:   C=US, S=California, L=Mountain View, O=Google Inc, CN=www.google.com
    Valid from:  5/3/2007 5:34:58 PM
    Valid until: 5/15/2008 1:18:11 AM
Import this certificate into the AddressBook store ?yes

1 certificate added to the stores.


And ran mozroots and imported everything it suggested.

Timothy.


On 29 Jan 2008, at 23:31, 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?
>
>
>
> 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/20080130/376a0b74/attachment-0001.html 


More information about the Mono-list mailing list