How to develop secure .NET applications using Server SSL Certificates and Client Certificates – PART 2
February 19, 2009 - 9:56 pm
The following article is part 2 in a 4 part series of articles about developing .NET applications using SSL. Part 1 in this series can be found here.
Setting Up Client Certificates
Client certificates can be used to authenticate the client connecting to a web application. The client can either be a browser or a custom written client application.
Requesting a client certificate:
- Open IE (Firefox didn’t work so well for me…) and type in:
http://<certauthservername>/certsrv/ - Click on the “Request a certificate” link.
- Click on the “Web Browser Certificate” link.
- Enter all required information into the form shown above click “Submit”
Issue the client certificate from your test Certification Authority:
- Log onto the Windows Server 2003 machine and open the Certification Authority dialog from Administrative Tools.
- Expand the root certification authority “Pending Requests” folder.
- The certificate you just requested should be in the “Pending Requests” folder. Right-click on this request and select All Tasks > Issue. The certificate request will be removed from the “Pending Requests” folder and appear in the “Issued Certificates”.
Retrieve the certificate and install it into the Current User > Personal Store:
- Go back to IE on your web server and type in
http://<certauthservername>/certsrv/again. - Click on the “View the status of a pending certificate request” link.
- Click on the certificate request you want to view.
- Click on the “Install this certificate” link.
- Click “Yes” on the dialog that opens to install the client certificate.
- Click “Yes” on the next dialog as well.
Requiring client certificates at web application with IIS:
Once a client certificate has been requested, issued and installed on a client machine, a web application can be set up to require client certificates. For extra security, client certificates can also be mapped to a windows account user.
- On the client machine, open a Microsoft Management Console with the Certificates snap-in. Export the client certificate without the private key. This will generate a .cer file. Copy this file over to the server hosting the web application.
- On the server hosting the web application, right-click the website in IIS and select “Properties”.
- Under Properties, go to the “Directory Security” tab.
- Under the Secure Communications section, click the “Edit” button.
- In the Secure Communications dialog, change the “Client Certificates” option to “Require client certificates” and check the “Enable client certificate mapping” checkbox.
- Click on the “Edit” button in the “Enable client certificate mapping” section.
- This will open up the Account Mappings dialog.
- Click the “Add” button.
- Select the client certificate .cer file recently exported from the server that hosts the client application or client browser.
- Give the mapping a relevant name and choose the windows user that the web application will be run under.
- Click OK.
- Click OK to close the Account Mappings dialog and Secure Communications dialogs.
- Remove all other authentication options in the IIS manager Directory Security setting by clicking on the “Edit” button under Anonymous access and authentication control in the Directory Security tab.
- Uncheck all authentication options and press OK.
- Open up a browser and verify that you cannot reach the web site unless you navigate to it from the machine that has the client certificate installed on it.
