srcnaks
srcnaks

Reputation: 243

WCF SSL connection configurations?

I wrote wcf service server and client aplications, both client and server works well with basic http binding. Now I want to change configuration to use SSL for connection. Is there any body that can explain how can I that and give an example about it

Thanks a lot

Upvotes: 2

Views: 5001

Answers (2)

Ron
Ron

Reputation: 918

http://www.codeproject.com/Articles/36705/7-simple-steps-to-enable-HTTPS-on-WCF-WsHttp-bindi This is a very simple and basic reference to using SSL on WCF Serice. I was in the same boat as you a while ago and my first question on SO was about HTTP/HTTPS Binding. I had a good discussion with one of the users on SO and they gave me a good idea about this Have a look at this. I have the web config which is the main for configuration HTTP and HTTPS Bindings

Hope this helps.

Upvotes: 0

Greg
Greg

Reputation: 11478

Here is a really nice article about just that and a nice post on Stack here.

The key will be within your Config file.

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicSecure">
          <security mode="Transport" />
        </binding>
      </basicHttpBinding>
    </bindings>
    <services>
      <service name="WcfServiceLibrary.Echo.EchoService">
        <endpoint 
          address="https://localhost:8888/EchoService/" 
          binding="basicHttpBinding"
          bindingConfiguration="BasicSecure" 
          contract="WcfServiceLibrary.Echo.IEchoService">
          <identity>
            <certificateReference 
              storeName="My" 
              storeLocation="LocalMachine"
              x509FindType="FindByThumbprint" 
              findValue="f1b47a5781837112b4848e61de340e4270b8ca06" />
          </identity>
        </endpoint>
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/" />
          </baseAddresses>
        </host>
      </service>
    </services>
<behaviors>
  <serviceBehaviors>
    <behavior name="">
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
  </system.serviceModel>

They thing to note here, is security mode = "Transport" and the CertificateReference. Those will be very, very important. You'll have to ensure your Ports are properly configured for this to work.

Keep in mind also wshttpBinding has this encryption enabled by default.

Good luck.

Upvotes: 3

Related Questions