title: Mono https webrequest fails with "The authentication or decryption has failed"
body: <p>I'm making a simple REST client to use in my C# applications. In .net on Windows It works great with http:// and https:// connections. In mono 2.6.7 (Also tested with 2.8 with the same results) on Ubuntu 10.10 only http:// works. https:// connections throw up this exception on the request.GetResponse() method:</p>
  
  <pre><code>Unhandled Exception: System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---&gt; System.IO.IOException: The authentication or decryption has failed. ---&gt; Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a
    at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in &lt;filename unknown&gt;:0 
    at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1 () [0x00000] in &lt;filename unknown&gt;:0 
    at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process () [0x00000] in &lt;filename unknown&gt;:0 
    at (wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process ()
    at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in &lt;filename unknown&gt;:0 
    at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in &lt;filename unknown&gt;:0 
    --- End of inner exception stack trace ---
    at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in &lt;filename unknown&gt;:0 
    --- End of inner exception stack trace ---
    at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in &lt;filename unknown&gt;:0 
    at System.Net.HttpWebRequest.GetResponse () [0x00000] in &lt;filename unknown&gt;:0 
  </code></pre>
  
  <p>I haven't been able to find any way to fix this. Anyone have any idea why this is happening and how to fix it?</p>
  
  <p>Again, this only fails in Mono, .Net doesn't seem to have any problem establishing a connection.</p>
  
  <p>here's the calling code:</p>
  
  <pre><code>public JToken DoRequest(string path, params string[] parameters) {
      if(!path.StartsWith("/")) {
          path = "/" + path;
      }
      string fullUrl = url + path + ToQueryString(parameters);
  
      if(DebugUrls) Console.WriteLine("Requesting: {0}", fullUrl);
  
      WebRequest request = HttpWebRequest.CreateDefault(new Uri(fullUrl));
      using(WebResponse response = request.GetResponse())
      using(Stream responseStream = response.GetResponseStream()) {
          return ReadResponse(responseStream);
      }
  }
  </code></pre>