I have written an ASP.NET MVC application. Within the application, I have written a rather simple method entitled GetClientCertificateCollection(). This method is supposed to simply return the current user's client certificates. When I execute this code in VisualStudio 2013 / IIS Express [debug mode], the logic works perfectly and I can process the user's X509 certificates without issue [I also retrieve the server's certificates, but I've written could to ignore them and only process through valid user certificates].
Unfortunately, when I deploy my solution to an instance of IIS on a web server, the method returns nothing; literally 0 certificates.
I have researched and tried a number of suggestions, but I have been unsuccessful in finding the smoking gun.
My IIS configuration is as follows: 1. Site is hosted as a sub-directory to the "Default Web Site". 2. Bindings - Port 443 enabled with an SSL certificate. 2. Authentication - All Disabled. 3. SSL Settings - Require SSL / Require.
I'm hopeful that someone can help point me in the right direction. Thanks in advance for your help.
public static X509Certificate2Collection GetClientCertificateCollection()
{
X509Store UserStore = new X509Store(StoreName.My, StoreLocation.CurrentUser)
try
{
UserStore.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
X509Certficate2Colllection certificatesInStore = UserStore.Certificates;
return certificatesInStore;
}
catch (Exception ex)
{
throw;
}
finally
{
UserStore.Close
}
}