I want to add mutual authentication to my client .NET application running under the IIS server (this is a web service that calls another web service). The client application downloads the client certificate from the file and works fine with the following code on my development machine (I tried Windows 7 and Windows 10 with .NET 4.6.2):
var handler = new WebRequestHandler();
var certificate = new X509Certificate2(clientCertPath);
handler.ClientCertificates.Add(certificate);
handler.AuthenticationLevel = AuthenticationLevel.MutualAuthRequired;
client = new HttpClient(handler);
But when this code is deployed to Windows 2016 Server, the application issues The request was aborted: Could not create SSL/TLS secure channel.
I turned on tracing for System.Net, this is what I see in the logs
SecureChannel
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
, IIS PFX. , IIS_IUSRS, All Tasks -> Manage Private Keys..., , .
, Windows Server, PFX ?