SSL Needs Certificates

There are many blogs out there describing how to configure a WCF service to use SSL (for example this one by Dominick Baier or this one at Microsoft’s that also shows how to do it in code). In short, here’s an example for such a configuration:

<configuration>

  <system.serviceModel>

    <services>
      <service name="WcfService2.Service1" behaviorConfiguration="sslServiceBehavior">

        <host>
          <baseAddresses>
            <add baseAddress="https://localhost:44301/ssltest" />
          </baseAddresses>
        </host>

        <!-- Expose the service over SSL -->
        <endpoint address="" binding="basicHttpBinding" contract="WcfService2.IService1"
                  bindingConfiguration="sslBinding"/>
        <!-- Expose the meta data over SSL -->
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />

      </service>
    </services>

    <bindings>
      <basicHttpBinding>
        <binding name="sslBinding">
          <!-- This line activates SSL -->
          <security mode="Transport"/>
        </binding>
      </basicHttpBinding>
    </bindings>

    <behaviors>
      <serviceBehaviors>
        <behavior name="sslServiceBehavior">
          <!-- Expose the meta data over SSL -->
          <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>

  </system.serviceModel>

</configuration>

So far, nothing new here. Also not new is that this won’t work if no certificate is assigned to the service’s address. So if you’re trying to connect to your service with a browser and see something like this, you might not have assigned a certificate:

notavailable

If you are asking how to assign a certificate, please read this.

One thought on “SSL Needs Certificates

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s