none
Self-hosted WCF service with SSL and IIS not working RRS feed

  • Question

  • I have a self-hosted WCF service and I have reserved the following url namespaces using netsh:

        http://localhost/v1/

        https://localhost:443/v1/

    And I have bound my SSL cert to 0.0.0.0:443 using netsh.

    All this works fine - I can access my service API at https://svc.foo.com/v1/apix... or http://svc.foo.com/v1/apix...

    But when I also run IIS, IIS claims my namespace, but only when using SSL! Result is that https://svc.foo.com/v1/apix returns error 404 (served by IIS), while http://svc.foo.com/v1/apix works fine (served by my service)

    What's going on? If the URL is reserved shouldn't IIS not try to serve it? And why is the SSL case different from the non-SSL case? Strange! Bottom line is that I can get IIS working OR my service but not both under SSL. Without SSL, both co-exist.

    Thanks in advance for any help or any clues as to how to diagnose this.


    John M

    Tuesday, May 19, 2015 11:44 PM

All replies

  • hi John,
       As per this case, check the following details which may guide you to resolve this issue :
    1.First you need to list the service in the <system.serviceModel> node like below :

    <system.serviceModel>
      <services>
        <service name="CustomerService.CustomerService"
                  behaviorConfiguration="MyServiceBehavior">
          <endpoint address=""
                    binding="basicHttpBinding"
                    bindingConfiguration="TransportSecurity"
                    contract="SampleService.ISampleService" />
    
          <endpoint address="mex"
                    binding="mexHttpsBinding"
                    contract="IMetadataExchange" />
        </service>
      </services>
    </system.serviceModel>
    

    2. You need to define this behavior in the <behaviors> node of the <system.serviceModel> node like below

    <behaviors>
      <serviceBehaviors>
        <behavior name="MyServiceBehavior">
          <serviceMetadata httpsGetEnabled="true" httpsGetUrl="" />
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    

    Note that the httpsGetEnabled property of the behavior is set to true. This allows you to retrieve metadata for the service using an HTTPS/GET request

    3.After created your ssl certificate then Goto IIS Manager :
    select the Default Web Site node >> In the right pane click on the “Bindings” link.
    Site Bindings popup>>click “Add” button>>
    Add Site Binding popup>>Type “https” >>ssl certificate “choose your certificate” >>Click ok

    4.Restart your web site and navigate to corresponding URL but you may get a warning message because of your SSL certificate may be untrusted . Just ignore it.

    5.for more information, Click here to refer about How to: Configure an IIS-hosted WCF service with SSL

    Wednesday, May 20, 2015 5:22 AM
  • Hi Eric,

    I think my WCF config is correct because my WCF service works properly using SSL or non-SSL when IIS is not running (this is a self-hosted WCF service). The problem is that once I turn IIS on, IIS takes over my URL, but it only does so for SSL - the non-SSL url continues to be served by my service.

    -John


    John M

    Wednesday, May 20, 2015 5:42 AM