title: Mono: HttpWebRequest SSL Errors on non-SSL URI
body: <p>I have a console application that I wrote for .NET/Windows that I suddenly had the need for on my unix system. Mono has, for the most part, been hugely successful at providing this for me.</p>
  
  <p>There is however a small issue:
  The application issues many HttpWebRequests as it runs, and for a small portion of these, Mono is returning an error:</p>
  
  <blockquote>
    <p>Error getting response stream (Write: The authentication or decryption has failed.): SendFailure</p>
  </blockquote>
  
  <p>This error message seems to indicate an SSL error. However, this application does not issue any request to SSL-secured URIs (i.e. all URIs are http://).</p>
  
  <p>The main code in question is as follows:</p>
  
  <pre><code>HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
  req.UserAgent = UserAgent;
  req.AuthenticationLevel = AuthenticationLevel.None;
  req.AllowAutoRedirect = true;
  req.KeepAlive = true;
  req.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
  req.Timeout = timeout;
  
  if (useCompression) {
      req.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate");
  }
  </code></pre>
  
  <p><strong>Edit:</strong> For the purposes of running this code, you can define dummy variables as follows:</p>
  
  <pre><code>string url = "http://example.com";
  string UserAgent = "WhateverBot";
  int timeout = 5000;
  bool useCompression = true;
  </code></pre>
  
  <p>It should be noted that the code works without any problem on Windows/.NET.</p>