title: Getting System.Net.WebException: Error: SendFailure (Error writing headers) when I run AppXXX.Droid, a Xamarin.Forms Portable project
body: <p>I have created a Xamarin.Forms Portable project which targets Android, iOS, UWP, Windows and WindowsPhone platforms. I am trying to make a Http request using HttpClient which uses System.Net.Http namespace. The application is trying to request some secure endpoints.  Here is a part of my code:</p>
  
  <pre><code>            HttpClientHandler handler = new HttpClientHandler();
              HttpClient httpClient = new HttpClient();
              HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, reqUrl);
  
  
              string charset = "UTF-8";
              string contentType = "application/json";
  
              bool isAuthOrReg = (reqUrl.Contains("/user/xxx") ||
                                  reqUrl.Contains("/user/xxx") ||
                                  reqUrl.Contains("/user/xxx));
  
              if (isAuthOrReg)
              {
                  request.Headers.Add("KEY", getKey());
                  request.Headers.Add("SECRET", getSecret());
              }
              request.Headers.Add("Accept-Charset", charset);
              request.Content = new StringContent(postData, Encoding.UTF8, contentType);
              request.Content.Headers.ContentLength = postData.Length;
  
              HttpResponseMessage response = await httpClient.SendAsync(request);
              string serverResponse =  await response.Content.ReadAsStringAsync();
  </code></pre>
  
  <p>When I run the project as a Windows 8.1 application, it works fine. but, when I run it as an Android application, I get 
      Unhandled Exception:</p>
  
  <pre><code>System.Net.WebException: Error: SendFailure (Error writing headers)"
  06-16 13:59:27.012 D/Mono    ( 1702): DllImport attempting to load:    '/system/lib/liblog.so'.
  06-16 13:59:27.012 D/Mono    ( 1702): DllImport loaded library '/system/lib/liblog.so'.
  06-16 13:59:27.012 D/Mono    ( 1702): DllImport searching in: '/system/lib/liblog.so' ('/system/lib/liblog.so').
  06-16 13:59:27.012 D/Mono    ( 1702): Searching for '__android_log_print'.
  06-16 13:59:27.012 D/Mono    ( 1702): Probing '__android_log_print'.
  06-16 13:59:27.012 D/Mono    ( 1702): Found as '__android_log_print'.
  06-16 13:59:27.040 I/MonoDroid( 1702): UNHANDLED EXCEPTION:
  06-16 13:59:27.064 I/MonoDroid( 1702): System.Net.WebException: Error:    SendFailure (Error writing headers) ---&gt; System.Net.WebException: Error writing headers ---&gt; System.IO.IOException: The authentication or decryption has failed. ---&gt; Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.
  06-16 13:59:27.065 I/MonoDroid( 1702):   at Mono.Security.Protocol.Tls.RecordProtocol.EndReceiveRecord (IAsyncResult asyncResult) [0x0003a] in /Users/builder/data/lanes/3236/ee215fc9/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/RecordProtocol.cs:430 
  06-16 13:59:27.065 I/MonoDroid( 1702):   at Mono.Security.Protocol.Tls.SslClientStream.SafeEndReceiveRecord (IAsyncResult ar, Boolean ignoreEmpty) [0x00000] in /Users/builder/data/lanes/3236/ee215fc9/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:285 
  06-16 13:59:27.065 I/MonoDroid( 1702):   at Mono.Security.Protocol.Tls.SslClientStream.NegotiateAsyncWorker (IAsyncResult result) [0x00071] in /Users/builder/data/lanes/3236/ee215fc9/source/mono/mcs/class/Mono.Security/Mono.Security.Protocol.Tls/SslClientStream.cs:447 
  06-16 13:59:27.065 I/MonoDroid( 1702):   --- End of inner exception stack trace ---
  </code></pre>
  
  <p>In my personal opinion, this is due to Android being unable to ignore ssl. So, I tried to add following by refering to <a href="https://stackoverflow.com/questions/28629989/ignore-ssl-certificate-errors-in-xamarin-forms-pcl">Ignore SSL certificate errors in Xamarin.Forms (PCL)</a></p>
  
  <pre><code> ServicePointManager
          .ServerCertificateValidationCallback +=
          (sender, cert, chain, sslPolicyErrors) =&gt; true;
  </code></pre>
  
  <p>But, I am getting the same error. Is there any way to solve this problem?
   Thanks.</p>