Does anybody know how to configure IIS Express to require client certificate for access? I'm trying to debug a problematic ASP.NET application which uses client certificates for authentication.
Does anybody know how to configure IIS Express to require client certificate for access? I'm trying to debug a problematic ASP.NET application which uses client certificates for authentication.
Use the IIS Manager tool and follow the Microsoft documentation IIS Client Certificate Mapping Authentication <iisClientCertificateMappingAuthentication>.
Sample config:
I found a blog that detailed how to configure client certificate requests for IIS Express (I used Visual Studio 2017, IISExpress 10.0). Apparently the location of the
applicationhost.config
files changed in Visual Studio 2015 and up.Here's an outline of what it says:
SSL Enabled
toTrue
(notice theSSL URL
property gets populated)https://localhost:44300
applicationhost.config
: In 2015 or 2017, the file is located in[solution directory]\.vs\config\
- in earlier versions it's found in%UserProfile%\Documents\IISExpress\config\
<access sslFlags="Ssl, SslNegotiateCert, SslRequireCert" />
and<iisClientCertificateMappingAuthentication enabled="true"></iisClientCertificateMappingAuthentication>
Request.ClientCertificate
property, and should be prompted when you open your page in the browser.These were the instructions handed out by Jason Shavers in his blog. (But that page no longer exists.) Scott Hanselman also talks about enabling SSL at http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx . But at no point does he refer to making the site require client certificates.
These are the instructions I followed:
Change applicationhost.config (There are two of these one at MyDocuments\IISExpress\config and the other at program files\IIS Express\AppServer by default the one under your profile is used when you run a project on IISExpress in VS 2012 The other can be run using the command line which is what I did on the local test machine.)
And the element
to
The next two steps have to both be performed in Visual Studio By default when a new project is create in VS 2012 then it is created as an IIS Express project. An older project transferred to VS2012 may have to actually change that setting.
On the Project properties page on the Web tab, change Use Visual Studio Developer Server to Use Local IIS web Server. (There should be a grayed out checkbox saying Use IIS Express if you don't have regular IIS install on you machine (which can't be done on these NMCI machines.) There should be a project URL saying something like http://Localhost:62714/ (which should be the same port that is set as "specific port" under the Visual Studio Development Server setting (if it is set)
Then select the Project on the solution explorer and go to the properties tab. (Sometimes this has to be done a couple of times before the properties show up.) This will have three properties, SSL Enable which defaults to false, SSL URL which is blank with a new project and URL which is set to the URL in "project URL" on the properties tab.
Change the SSL enabled property to true, and a new SSL URL will be created.
On the applicationhost.config file under the the "" element a new entry is made when the project is first run before you enable SSL. It will look like this:
When you enable SSL on your project, it should look like this:
(all 443xx ports are reserved for SSL projects).