title: Using a self-signed certificate with .NET's HttpWebRequest/Response
body: <p>I'm trying to connect to an API that uses a self-signed SSL certificate. I'm doing so using .NET's HttpWebRequest and HttpWebResponse objects. And I'm getting an exception that:</p>
  
  <blockquote>
    <p>The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.</p>
  </blockquote>
  
  <p>I understand what this means. And I understand <em>why</em> .NET feels it should warn me and close the connection. But in this case, I'd like to just connect to the API anyway, man-in-the-middle attacks be damned.</p>
  
  <p>So, how do I go about adding an exception for this self-signed certificate? Or is the approach to tell HttpWebRequest/Response not to validate the certificate at all? How would I do that?</p>