Hosting WCF 4.0 Service on IIS 7.5 with SSL
Posted by: Mahesh Sabnis ,
on 4/1/2010,
in
Category Windows Communication Foundation (WCF)
Abstract: This article is Part 2 of the two part series where I demonstrate how to create a certificate, create a WCF service that uses this certificate and finally host a WCF service on IIS 7.5 with SSL. In this article, we will see how to host a WCF service we created in Part 1, on IIS 7.5 with SSL.
Hosting WCF 4.0 Service on IIS 7.5 with SSL
Note: The same steps can also be followed for IIS 7.0.
Step 1: Open IIS 7.5 and create a new Application Pool. To do this, follow the steps shown below:
· Right click on ‘Application Pools’ and select ‘Add Application Pool’,
Remember you need to set the .NET Framework Version to 4.0, this will use ASP.NET 4.0 process to handle requests.
· Right Click on the Application pool you have created, and select ‘Advanced Settings’ from the ‘Process Model’ group and change the ‘Identity’ to ‘LocalSystem’ as shown below:
Step 2: Right click on the ‘Sites’ and select ‘Add New Web Site’. Provide ‘Site Name’, using ‘Select’ button and select the application pool which you have created in the ‘Step 1’. Provide a Physical Path for the web site. In the ‘Binding’, select ‘Https’. This will select the 443 port number. Once you select https, it will show a combobox for SSL certificate selection for the web site. Select the certificate which you have created. You will see the window shown below:
Step 3: To the web site you have created, right click and select ‘Add Application’ by following the screen shot below:
Step 4: Switch back to the VS2010 and to publish the WCF service in this web site, right click on the WCF Service and select ‘Publish’ as below:
(Note: By default you will have ’Web Deploy’ as ‘Publish Method’, change it to ‘File System’ and from the Target location, select ‘Local IIS’ and navigate to the web site and the application which you have created in previous step), the following window will be displayed:
Click on ‘Publish’.
Step 5: Switch back to IIS and expand the web site and application where the WCF service is published > switch to content view > you will see the following window:
Step 6: Right click on ‘Service.svc’ and click on browse, the browser will open the url with the following output:
This means that the certificate which we have configured is not issued by a trusted certificate authority. Now since we are just giving a demo here, the option of ‘Continue to this website’ can be selected. But remember that in a production scenario, you must be careful and resolve the certificate issue. So after selecting the continue option, the following output will be displayed:
Now the WCF service is successfully hosted. You can now use this service in your client application.
Conclusion: SSL provides an effective security mechanism for the communication between Client applications and WCF services.
Give me a +1 if you think it was a good article. Thanks!