Posts

....
Technical Blog for .NET Developers ©

Monday, September 30, 2013

WCF Enable SSL

In order to include HTTPS binding to our REST Services in IIS, we have to set up the service to accept SSL Certificates

We must have installed the Certificate on IIS



Browse to the WCF Rest Service Application, click on SSL Configuration, and set up the service to accept client certificates



Now our service works under HTTPS binding, to enable both protocols, we must write two different endpoints referring the service, and stablish the behavior configuration for http and https

     
    <behavior name="ServiceBehavior">
       <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
         <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>      
    
    <%--...--%>
    
    <bindings>
      <webHttpBinding>
        <binding name="BindHttp" crossDomainScriptAccessEnabled="true">
        </binding>      
        <binding name="BindHttps" crossDomainScriptAccessEnabled="true">
            <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    
    <%--...--%>
    
    <services>
      <service behaviorConfiguration="ServiceBehavior" name="WCFRestService.RestService">
        <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
          bindingConfiguration="BindHttp" contract="WCFRestService.IRestService" />      
        <endpoint address="" behaviorConfiguration="web" binding="webHttpBinding"
          bindingConfiguration="BindHttps" contract="WCFRestService.IRestService" />          
      </service>
    </services>
    


<METHOD SOFTWARE ©>