title: Can't move from calling TLS authenticated Web API from console application to ASP.NET MVC IIS hosted application
body: <p>I've followed a tutorial on how to create a TLS secured Web API using OWIN and Katana. Everything works fine when I access the Web API using a console application as the client.</p>
  <p>But, what I'd like to do is access the API in another ASP.NET MVC site hosted in IIS. When I move the code into a basic controller I get the error</p>
  <blockquote>
  <p>The request was aborted: Could not create SSL/TLS secure channel</p>
  </blockquote>
  <p>I've looked at some other posts that discuss configuring <code>System.Net.ServicePointManager.SecurityProtocol</code> so I've tried that but it doesn't seem to change anything.</p>
  <p>I have both sites hosted in IIS using Windows Server 2012 R2 and targeting .NET 4.6.</p>
  <p>Code that works in a console application using a client cert but installed under LocalMachine:</p>
  <pre><code>static void Main(string[] args)
  {
      var handler = new WebRequestHandler();
  
      handler.ClientCertificates.Add(X509.LocalMachine.My.SubjectDistinguishedName.Find(&quot;CN=client&quot;).First());
  
      var client = new HttpClient(handler)
          {
              BaseAddress = new Uri(&quot;https://admin.web/api/&quot;)
          };
  
      var response = client.GetAsync(&quot;identity&quot;).Result;
      response.EnsureSuccessStatusCode();
  
      var content = response.Content.ReadAsStringAsync().Result;
      Console.WriteLine(JArray.Parse(content));
  }
  </code></pre>
  <p>Code that is failing in basic controller when moved into an ASP.NET MVC site:</p>
  <pre><code>using System.Web.Mvc;
  using System.Net.Http;
  using System;
  using Thinktecture.IdentityModel;
  using System.Linq;
  using System.Net;
  
  namespace DataClientWeb.Controllers
  {
      public class DefaultController : Controller
      {
          // GET: Default
          public ActionResult Index()
          {
              System.Net.ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
  
              var handler = new WebRequestHandler();
  
              handler.ClientCertificates.Add(
                  X509.LocalMachine.My.SubjectDistinguishedName.Find(&quot;CN=client&quot;).First());
  
              var client = new HttpClient(handler)
              {
                  BaseAddress = new Uri(&quot;https://admin.web/api/&quot;)
              };
  
              var response = client.GetAsync(&quot;identity&quot;).Result;
              response.EnsureSuccessStatusCode();
  
              return View();
          }
      }  
  }
  </code></pre>
  <p>I haven't secured web applications using client certificates for authentication before so it's possible I'm just missing something simple here. Any pointers are appreciated.</p>