title: C# Enforcing HttpWebRequest to use Tls12 instead of SSLv3
body: <p>I have App that makes use of some web service and acquire data via JSON, all was working fine for quite long time, up until latest discoveries about SSLv3 being vulnerable to man-in-the-middle attacks and server owners turning off SSLv3 for good. My application started to have problems connecting and returned error  "Request was aborted: cannot establish secure SSL/TLS connection". I've tried to look for solution and found information i got to add this code before creating web request:         </p>
  
  <pre><code>        ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
          ServicePointManager.ServerCertificateValidationCallback = delegate{ 
                      return true;
          };
  </code></pre>
  
  <p>Unfortunately no luck here, app acts the same as before, and I have no clue if this code does nothing or there is still some problem with server. Error information is pretty vague and i have problem figuring where things go wrong. </p>
  
  <p>Here is my code</p>
  
  <pre><code>        ...
          HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
          request.ContentType = GetRequestContentType();
          request.Method = method.ToString();
          request.Credentials = GetCredential(url);
          request.PreAuthenticate = true;
          CookieContainer cookieContainer = new CookieContainer();
          request.CookieContainer = cookieContainer;
          ...
  </code></pre>
  
  <p>I want to ask how to set <strong>Tls12</strong> to be used as default and ensure that at my end request I make is with desired protocol. </p>
  
  <p>If I confirm that my app at my end works fine, is there way to get more detailed information from server response and pinpoint precise reason of error?</p>
  
  <p>Thanks for all answers and suggestions.</p>
  
  <p><strong><em>EDIT</em></strong></p>
  
  <p>Second part of question is solved, I found this tool <a href="http://www.telerik.com/download/fiddler" rel="noreferrer">http://www.telerik.com/download/fiddler</a> it pretty much allows to see what is going on with outgoing and incoming data. There is also thing that this tool allow to decode SSL connections, enabling this option makes that my application starts to work. I assume that this app does something that make communication between my app and destination host possible. But i do still have no idea what it could be. And how to make my app to handle these connections properly by itself.</p>