For highly secure Web applications, such as Internet banking sites, you may want to implement a more secure solution for user authentication than the user name and password combination. You can use client-side digital certificates to verify the identity of the user. In addition, you can map client-side digital certificates to Windows accounts on the server if necessary.
back to the topRequirements
The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
- Microsoft Windows 2000 Service Pack 2 Server
- Microsoft Internet Explorer 6.0
- Microsoft Visual Studio .NET
- Microsoft Certificate Services (if you must generate your own certificates)
This article assumes that you are familiar with the following topics:
- ASP.NET development with Visual Basic or Visual C#
- Microsoft Internet Information Services (IIS) configuration
back to the topCreate the ASP.NET Web Application
In this section, you create a simple ASP.NET application. In the sections to follow, you will use client-side certificate authentication to secure this application.
- Start Visual Studio .NET, and then create a new ASP.NET Web Application project named SecureSite.
- Drag a Label control from the toolbox onto the WebForm1.aspx Web form, and then set its ID property to greetingLabel.
- Drag a second Label control onto WebForm1.aspx, and then set its ID property to certDataLabel.
- Add the following code to the Page_Load event procedure:
'Visual Basic
Dim username As String
userName = User.Identity.Name
greetingLabel.Text = "Welcome " & userName
Dim cert As HttpClientCertificate = Request.ClientCertificate
If cert.IsPresent Then
'Get the Organization (O) field from the Subject section.
certDataLabel.Text = cert.Get("Subject O")
Else
certDataLabel.Text = "No certificate was found."
End If
//Visual C#
string userName;
userName = User.Identity.Name;
greetingLabel.Text = "Welcome " + userName;
HttpClientCertificate cert = Request.ClientCertificate;
if (cert.IsPresent)
certDataLabel.Text = cert.Get("SUBJECT O");
else
certDataLabel.Text="No certificate was found.";
- Build and save the project, and then close Visual Studio.
- Start Internet Explorer, and then browse to the following page:
http://localhost/SecureSite/WebForm1.aspx
Notice that the page displays the "Welcome" and "No certificate was found" messages. Notice that the page does not display a user name because the user has not been authenticated. - Close Internet Explorer.
back to the topConfigure the Web Server for Certificate-Based Authentication
In this section, you configure the SecureSite project to use certificates for authentication. To use client-side certificates, you must install a server-side certificate. You can use an existing server certificate from any certificate authority, or you can generate a server-side certificate with Microsoft Certificate Services.
back to the topTo Create a Server-Side Certificate Request
- On the Start menu, point to Programs, point to Administrative Tools, and then click Internet Services Manager.
- Expand the node for your server, and then click Default Web Site.
- On the Action menu, click Properties.
- On the Directory Security tab, click Server Certificate. Follow these steps in the wizard:
- Click Next on the first page of the wizard.
- On the Server Certificate page, click Create a new certificate, and then click Next.
- On the Delayed or Immediate Request page, click Prepare the request now, but send it later, and then click Next.
- On the Name and Security Settings page, accept the default settings, and then click Next.
- On the Organization Information page, type MSDN for the organization, type How To Articles for the organizational unit, and then click Next.
- On the Your Site's Common Name page, type localhost, and then click Next.
- On the Geographical Information page, type your country, region, and city details, and then click Next.
- On the Certificate Request File Name page, accept the default file name (usually c:\certreq.txt), and then click Next.
- On the Request File Summary page, confirm that all of the details are correct, and then click Next.
- Click Finish to close the wizard.
- Open the certificate file that is generated, and then copy the entire contents of the certificate file to the clipboard.
back to the topTo Submit a Server-Side Certificate Request
- Start Internet Explorer, and then browse to the following page:
http://localhost/CertSrv
NOTE: The Microsoft Certificate Services must be installed. - Follow these steps in the wizard:
- Click Request a Certificate, and then click Next.
- On the Choose Request Type page, click Advanced request, and then click Next.
- On the Advanced Certificate Requests page, click Submit a certificate request using a base64 encoded PKCS#10 file, and then click Next.
- On the Submit a Saved Request page, click in the Base64 Encoded Certificate Request (PKCS #10 or #7) box, and then press the CTRL+V key combination to paste the certificate request that you copied to the clipboard earlier. Click Submit.
- Close Internet Explorer.
back to the topTo Issue a Server-Side Certificate
- On the Start menu, point to Programs, point to Administrative Tools, and then click Certificate Authority.
- Expand the node for your certificate authority, and then select Pending Requests.
- Select the certificate request that you just submitted. On the Action menu, point to All Tasks, and then click Issue.
- Confirm that the certificate appears in the Issued Certificates folder, and then double-click the certificate to view it.
- On the Details tab, click Copy to File. Save the certificate as a Base-64 encoded X.509 certificate to C:\Servercert.cer.
- Close the Properties dialog box for the certificate.
- Close the Certificate Authority tool.
back to the topTo Install a Server-Side Certificate
- On the Start menu, point to Programs, point to Administrative Tools, and then click Internet Services Manager.
- Expand the node for your server, and then click Default Web Site.
- On the Action menu, click Properties.
- On the Directory Security tab, click Server Certificate. Follow these steps in the wizard:
- Click Next on the first page of the wizard.
- Click Process the Pending Request to install the certificate, and then click Next.
- Browse to the C:\Servercert.cer certificate file that you saved previously. Click Next twice, then click Finish.
- Click OK to close the Properties dialog box.
back to the topTo Configure SecureSite Site for SSL and Client-Side Certificates
- In Internet Services Manager, select the SecureSite subweb, and view its properties.
- Follow these steps in the wizard:
- On the Directory Security tab, click Edit in the Secure communications section.
- Select the Require secure channel (SSL) check box. This ensures that communications to this subweb are encrypted.
- Select the Require client certificates check box. This ensures that the site can only be viewed by users who have a client-side certificate installed.
- Select the Enable client certificate mapping check box. This is used to map client certificates to Windows user accounts.
- Click Edit. Notice that you can map each certificate to an individual Windows account, or you can map many certificates to the same Windows account.
- On the Many-to-1 tab, click Add to add a mapping rule. Name this rule Mapping Rule, and then click Next.
- Click New to create a new rule in which the O sub field (Organization) of the Subject section of the certificate has the criteria "MSDN". Click OK to apply the mapping to users whose certificates contain an Organization attribute of "MSDN". In a production environment, the mapping rule is stricter and often validates the issuer of the certificate as well as the subject. Click Next.
- On the Mapping page, select Accept this certificate for Logon Authentication. Click Browse to select the Windows account that you want to map MSDN users to. For this example, use the Administrator account. (In a real application, you create a dedicated Windows account with restricted privileges.) Make sure that you type the correct password.
- Click Finish, and then confirm the password.
- Click OK to close the Account Mappings dialog box.
- Click OK to close the Secure Communications dialog box. If you are prompted to apply the settings to child files and folders, click Select All, and then click OK.
- Click OK to close the SecureSite Properties dialog box.
back to the topTo Verify Certificate-Based Authentication
- Start Internet Explorer, and then browse to the following page:
https://localhost/SecureSite/WebForm1.aspx
Notice that you use the secure protocol, https. - Confirm that you receive a message that the page requires a client certificate.
- Close Internet Explorer.
back to the topInstall a Client Certificate
In this section, you install a client-side certificate. You can use a certificate from any certificate authority, or you can use Microsoft Certificate Services to generate your own certificate.
back to the topTo Request a Client-Side Certificate
- Start Internet Explorer, and then browse to the following page:
http://localhost/CertSrv
- Follow these steps in the wizard:
- Click Request a Certificate, and then click Next.
- On the Choose Request Type page, click Web Browser Certificate, and then click Next.
- Type the required information. Make sure that you type MSDN in the Company text box.
- Click Submit to complete the request.
- Close Internet Explorer.
back to the topTo Issue a Client-Side Certificate
- Start the Certificate Authority tool from the Administrative Tools program group.
- Expand the node for your certificate authority, and then select Pending Requests.
- Select the certificate request that you just submitted. On the Action menu, point to All Tasks, and then click Issue.
- Confirm that the certificate appears in the Issued Certificates folder, and then double-click the certificate to view it.
- On the Details tab, click Copy to File. Save the certificate as a Base-64 encoded X.509 certificate to C:\Clientcert.cer.
- Close the Properties dialog box for the certificate.
- Close the Certificate Authority tool.
back to the topTo Install a Client-Side Certificate
- Open Windows Explorer, and double-click Clientcert.cer to view the certificate file.
- Follow these steps in the Certificate Import Wizard:
- On the first page of the wizard, click Install Certificate, and then click Next.
- Select the Automatically select the certificate store based on the type of certificate check box, and then click Next.
- Click Finish to complete the wizard.
- Dismiss the confirmation message box, and then click OK to close the certificate.
back to the topVerify That It Works
In this section, you verify that client applications with certificates that specify "MSDN" as the company can view the SecureSite site. Users are mapped to the account that you specified in the mapping rule.
- Start Internet Explorer, and then browse to the following page:
https://localhost/SecureSite/WebForm1.aspx
- Confirm that:
- The Web page appears.
- The appropriate Windows account is used.
- The organization "MSDN" is read from the certificate.
back to the top