To perform authorization, Web services often need to be able to authenticate their callers (other applications. Client certificates provide a good authentication mechanism for Web Services. If you use a client certificate, your application will also benefit from creating a secure channel between the client application and the Web Service (using Secure Sockets Layer [SSL]). In this way, you can securely transmit confidential information between Web Services. SSL ensures the integrity and confidentiality of messages.
This "how to do" includes step-by-step instructions for calling Web services configured to require client certificates.
Note: The information in "how to do" applies to Remote components hosted by IIS.
Requirements
The following describes the recommended hardware, software, network infrastructure, skills, and knowledge as well as the service packages you need.
● Microsoft with Service Pack 2? Windows? 2000 Server Operating System
● Microsoft Visual Studio? . NET Development System
● Access the Certificate Authority (CA) to generate a new certificate
● A Web server with a server certificate installed
For more information about installing Web server certificates, see "how to do: Set SSL on Web servers" in the "Reference" section of this Guide ".
In this "how to do" process, you need to use Microsoft Visual C #? Development tools for ASP. NET Web development knowledge.
Summary
This "how to do" includes the following process:
1. Create a simple Web Application
2. Configure the Web application as a client certificate
3. client certificate needs to be installed and
4. Verify client certificate operations
1. Create a simple Web Application
U to create a simple Web Application
1. Start Visual Studio. NET and create a new C # ASP. NET Web application named SecureApp.
2. Drag a label control from the toolbox to the WebForm1.aspx Web form, and set its ID attribute to message.
3. Drag and Drop a tag to the WebForm1.aspx form and set its ID attribute to certData.
4. Add the following code to the Page_Load event.
String username;
Username = User. Identity. Name;
Message. Text = "Welcome" + username;
HttpClientCertificate cert = Request. ClientCertificate;
If (cert. IsPresent)
{
CertData. Text = "Client certificate retrieved ";
}
Else
{
CertData. Text = "No client certificate ";
}
5. In the "build" menu, click "build solution"
6. Start Internet Explorer and navigate to http: // localhost/SecureApp/WebForm1.aspx.
The "welcome" message (the user name is not displayed because the user has not been authenticated) and "no client certificate" should be displayed on the page ".
7. Disable Internet Explorer.
2. Configure the Web application as a client certificate
In this process, Internet Information Service (IIS) is used to configure the virtual directory of the Web application to require a certificate.
This process assumes that you have installed a valid certificate on the Web server. For more information about how to install a Web server certificate, see "How to: Set SSL on a Web server ".
U. Configure the virtual directory of the Web application as the certificate required
1. Start IIS on the Web service host.
2. navigate to the SecureApp virtual directory.
3. Right-click SecureApp and click "properties ".
4. Click the "Directory Security" tab.
5. Click "edit" under "Secure Communication ".
If you cannot use "edit", the Web server certificate may not be installed.
6. Select the "require secure channel (SSL)" check box.
7. Select the "client certificate required" option.
8. Click OK, and then click OK ".
9. In the "inherit overwrite" dialog box, click "select all", and then click "OK" to close the "SecureApp properties" dialog box.
This applies the new security settings to all subdirectories under the virtual root directory.
10. To confirm that the Web site is correctly configured, start Internet Explorer and (Use HTTPS) browse to https: // localhost/secureapp/webform1.aspx.
11. The "customer authentication" dialog box is displayed in Internet Explorer. You must select a client certificate. Because you have not installed the client certificate, click "OK" to confirm the error page that notifies you that the client certificate is required.
12. Disable Internet Explorer.
3. client certificate needs to be installed and
Install the client certificate in this process. You can use a certificate from any certificate authority or use the Microsoft Certificate Service described in the following sections to generate your own certificate.
This process assumes that the Microsoft Certificate Service is configured for a pending application, which requires the administrator to issue a dedicated certificate. It can also be configured to apply for automatic issuance of certificates.
U check Certificate Application Status settings
1. on the Microsoft Certificate Service computer, select certificate authority from the Administrative Tools program group ".
2. Expand Certificate Authority (local), right-click the Certificate Authority, and click Properties ".
3. Click the "Policy module" tab and click "Configure ".
4. Check the default operation.
The following process assumes that "the certificate application status is set to TBD ". Select "The Administrator must issue a certificate specially ".
U apply for client certificate
1. Start Internet Explorer and navigate to http: // hostname/certsrv. hostname is the name of the computer on which Microsoft Certificate Service is installed.
2. Click Apply for certificate, and then click Next ".
3. On the "select Application Type" page, click "User Certificate" and then click "Next ".
4. Click Submit to complete the application.
5. Disable Internet Explorer.
U issues client certificates
1. Start the Certificate Authority tool from the Administrative Tools program group.
2. Expand your certificate authority and select the "pending application" folder.
3. Select the certificate application you just submitted, point to "all tasks" on the "operations" menu, and click "issue ".
4. confirm that the certificate is displayed in the "issue Certificate" folder and double-click it to view the certificate.
5. On the Details tab, click Copy to file to save the certificate as a Base-64 encoded X.509 Certificate.
6. Close the certificate Properties window.
7. Disable the Certificate Authority tool.
U install client certificate
1. To view the certificate, start Windows Resource Manager, navigate to the. cer file saved in the previous process, and double-click it.
2. Click "Install Certificate", and then click "Next" on the homepage of the "Certificate import wizard ".
3. Select "automatically select the certificate storage area based on the certificate type", and then click "Next ".
4. Click "finish" to complete the wizard. In the close confirmation message box, click OK to close the certificate.
4. Verify client certificate operations
This process verifies whether you can use the client certificate to access the SecureApp application.
U verify client certificate operation
1. Start Internet Explorer and navigate to https: // localhost/secureapp/webform1.aspx.
2. confirm that the Web page is displayed successfully.