title: HttpClient with client certificate loaded from file
body: <p>I want to add mutual authentication to my client .NET application that is running under IIS server (it's a web service that calls another web service). Client app loads client certificate from file and it works fine with the following code on my development machine (I tried Windows 7 and Windows 10 with .NET 4.6.2):</p>
  
  <pre><code>var handler = new WebRequestHandler();
  var certificate = new X509Certificate2(clientCertPath); -- PFX file with client cert and private key 
  handler.ClientCertificates.Add(certificate);
  handler.AuthenticationLevel = AuthenticationLevel.MutualAuthRequired;
  client = new HttpClient(handler);
  </code></pre>
  
  <p>But when this code is deployed to production Windows 2016 Server machine the application throws <code>The request was aborted: Could not create SSL/TLS secure channel.</code> </p>
  
  <p>I enabled tracing for <code>System.Net</code> this is what I see in logs</p>
  
  <pre><code>SecureChannel#66407304 - Certificate is of type X509Certificate2 and contains the private key.
  AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
  AcquireCredentialsHandle() failed with error 0X8009030D.
  AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
  AcquireCredentialsHandle() failed with error 0X8009030D.
  Exception in HttpWebRequest#60537518:: - The request was aborted: Could not create SSL/TLS secure channel..
  </code></pre>
  
  <p>As it turned out this error is caused due to the lack of IIS user's permissions to read private key in PFX file. So when I import it into machine certificate store and add <code>IIS_IUSRS</code> by clicking right-button on client certificate <code>All Tasks -&gt; Manage Private Keys...</code> everything works fine, but I want to avoid that.</p>
  
  <p>Is there a way to work with client certificate loaded from file on Windows Server and don't import client certificate PFX file into certificate store? </p>