Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable SSL for my WCF service

Tags:

ssl

wcf

I have a WCF service that uses basicHttpbinding in development.

Now in product we want to use SSL, what changes do I have to make to force SSL connections only?

like image 532
Blankman Avatar asked Jan 08 '09 21:01

Blankman


People also ask

How do I enable ssl in IIS?

In Internet Information Services (IIS) Manager, under Connections, expand your server's name, expand Sites, and then select the website on which you want to install the SSL Certificate. In the Actions menu, under Edit Site, click Bindings. In the Site Bindings window, select binding for https and then, click Edit.


2 Answers

This page on MSDN explains WCF Binding Security.

http://msdn.microsoft.com/en-us/library/ms729700.aspx

The BasicHttpBinding class is primarily used to interoperate with existing Web services, and many of those services are hosted by Internet Information Services (IIS). Consequently, the transport security for this binding is designed for seamless interoperation with IIS sites. This is done by setting the security mode to Transport and then setting the client credential type. The credential type values correspond to IIS directory security mechanisms. The following code shows the mode being set and the credential type set to Windows. You can use this configuration when both client and server are on the same Windows domain.

C#

BasicHttpBinding b = new BasicHttpBinding(); b.Security.Mode = BasicHttpSecurityMode.Transport ; b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows; 

Or, in configuration:

<bindings>       <basicHttpBinding>             <binding name="SecurityByTransport">                <security mode="Transport">                  <transport clientCredentialType="Windows" />                 </security>             </binding>       </basicHttpBinding>  </bindings> 

To enable ssl, without a login, set clientCredentialType to "None".

Options for security mode are:

None, Transport, Message, TransportWithMessageCredential and TransportCredentialOnly

You can find more details at: http://msdn.microsoft.com/en-us/library/system.servicemodel.basichttpsecuritymode.aspx

like image 117
Stever B Avatar answered Sep 20 '22 17:09

Stever B


I just faced the same problem and found this MSDN article: How to: Configure an IIS-hosted WCF service with SSL At the end of the article you will find the xml configuration of the WebConfig file.

The solution worked just fine for me. One more thing to say, keep in mind that you need a REAL certificate for your release!

like image 26
Christoph Avatar answered Sep 21 '22 17:09

Christoph