title: Using C# to authenticate an SSL certificate
body: <p>I'm trying to communicate with a backend server using SSL.
  I'm trying using HttpClient from the System.Net.Http library, but I couldn't get it working.
  This is my code (Debug.Log is just a print since I'm using Unity):</p>
  
  <pre><code>public static async Task DownloadPageAsync(string web)
   {
       try
       {
           HttpClient cl = new HttpClient();
           string body = await cl.GetStringAsync(new Uri(web));
  
           Debug.Log(web);
       }
       catch (HttpRequestException e)
       {
           Debug.Log(e.InnerException.Message);
       }
       catch (Exception ex)
       {
           Debug.Log(ex.ToString());
       }
   }
  </code></pre>
  
  <p>When I try it in a web with a bad certificate, it gives: "Error: TrustFailure (The authentication or decryption has failed.)", which is fine. The problem is that good certificates also triggers an error: "Error: SecureChannelFailure (The authentication or decryption has failed.)".</p>
  
  <p>I've saw other answers saying that simply accepting all the certificates works fine, but I need to check if it's a valid certificate or not.</p>
  
  <p>¿Is there a way of doing it with HttpClient? ¿Or with some other class?</p>
  
  <p>Btw, I'm only using it to send POST request, and receiving a simple string.</p>
  
  <p>Thank you!</p>