locked
WCF Authentication Service with SSL encryption RRS feed

  • Question

  • User-842567297 posted

    Dear friends,

    I have created a WCF authentication service and all works well. When I am trying to implement SSL encryption to the communication, I get the following error: 

    There was no channel actively listening at 'https://myDomain/WebSite/MyAuthenticationSvcWrap.svc'. This is often caused by an incorrect address URI. Ensure that the address to which the message is sent matches an address on which a service is listening.

    The web.config of the http service host:

    <system.serviceModel>
        
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    
        <services>
          <service behaviorConfiguration="AppServiceBehaviors" name="WebSite.System.Web.ApplicationServices.AuthenticationService">
            <endpoint binding="basicHttpBinding" bindingConfiguration="Binding1" bindingNamespace="http://asp.net/ApplicationServices/v200" contract="WebSite.System.Web.ApplicationServices.AuthenticationService" />
          </service>
        </services>
    
        <bindings>
          <basicHttpBinding>
            <binding name="Binding1" >
              <security mode="None">
                <transport clientCredentialType="None" proxyCredentialType="None"
                    realm="" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>   
        
        <behaviors>
          <serviceBehaviors>
            <behavior name="AppServiceBehaviors">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    
    

    and client app.config:

    <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_AuthenticationService">
                        <security mode="None">
                          <transport clientCredentialType="None" proxyCredentialType="None"/>                        
                        </security>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="http://mydomain/WebSite/MyAuthenticationSvcWrap.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService"
                    contract="AuthenticationService" name="BasicHttpBinding_AuthenticationService" />
            </client>
        </system.serviceModel>

     The https service host:

    <system.serviceModel>
        
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    
        <services>
          <service behaviorConfiguration="AppServiceBehaviors" name="WebSite.System.Web.ApplicationServices.AuthenticationService">
            <endpoint binding="basicHttpBinding" bindingConfiguration="Binding1" bindingNamespace="http://asp.net/ApplicationServices/v200" contract="WebSite.System.Web.ApplicationServices.AuthenticationService" />
          </service>
        </services>
    
        <bindings>
          <basicHttpBinding>
            <binding name="Binding1" >
              <security mode="Transport">
                <transport clientCredentialType="None" proxyCredentialType="None"
                    realm="" />
              </security>
            </binding>
          </basicHttpBinding>
        </bindings>   
        
        <behaviors>
          <serviceBehaviors>
            <behavior name="AppServiceBehaviors">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    

    and app.config of client: 

    <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="BasicHttpBinding_AuthenticationService">
                        <security mode="Transport">
                          <transport clientCredentialType="None" proxyCredentialType="None"/>                        
                        </security>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="https://mydomain/WebSite/MyAuthenticationSvcWrap.svc"
                    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_AuthenticationService"
                    contract="AuthenticationService" name="BasicHttpBinding_AuthenticationService" />
            </client>
        </system.serviceModel>
    

    Actually I have changed the mode attribute of the <security> element to Transport in the basicHttpBinding of both files and also changed the client endpoint address from http to https. I must also note here that by hitting https://mydomain/WebSite/MyAuthenticationSvcWrap.svc in a browser finds the page and gets a response. 

    Can anybody suggest why this behaviour might be happening?

    Thanks alot

    Tuesday, September 8, 2015 4:04 PM

Answers

  • User-842567297 posted

    Hi Lorris, thanks for your answer.

    I finally managed to resolve the issue, although the answer doesn't make things any better for me, clarity-wise.

    The solution was to tick "Require SSL" at SSL Settings in IIS. It doesn't make any sense because the way I perceive it, if Require SSL is not ticked, means that an SSL request can still be handled the same way.

    Furthermore, the error messages continued, although this time were easier to resolve. It proved out that if the Security mode was set to 'Transport', I had to omit the Assembly name from the name attribute of the <service> element. In other words, it had to be exactly the same with the service name declared in the .svc file. In my case System.Web.ApplicationServices.AuthenticationService, while WebSite.System.Web.ApplicationServices.AuthenticationService was giving an error. The contract attribute had to be changed accordingly.

    What surprises me though is not why this happened but why this did not happen when the mode attribute was set to 'Nothing'. Although my application now works the way I want, I would still like to gain insight to the previous issues for the shake of gaining a better understanding. If anyone can help any further, I would be grateful.

    Thanks alot.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 9, 2015 6:07 PM

All replies

  • User1223857158 posted

    Hi saloom,

    If the problem occurs after you deployed the WCF service(web hosted) to IIS server, there might has something wrong with the deployment. You could refer to the following thread:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/91f460c2-02c8-4b00-ac96-b6358fbec133/wcf-there-was-no-channel-actively-listening?forum=wcf

    Solution which contains in above link:

    First, try using webbrowser to access an ASPX page or html page in the WCF service's deployment virtual directory. This can ensure whether the IIS virtual directory works correctly and http request can correctly access it.

    Regarding on the error message you received, I found an issue which pointed out a problem when you perform "precompile" on your website project when deploying to IIS:

    https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=300011

    Are you using "publish website" and deselect "allow site to be updatable" option? You can have a look at the above link to verify this.

    Hope it can help you.

    Wednesday, September 9, 2015 5:38 AM
  • User-842567297 posted

    Hi Lorris, thanks for your answer.

    I finally managed to resolve the issue, although the answer doesn't make things any better for me, clarity-wise.

    The solution was to tick "Require SSL" at SSL Settings in IIS. It doesn't make any sense because the way I perceive it, if Require SSL is not ticked, means that an SSL request can still be handled the same way.

    Furthermore, the error messages continued, although this time were easier to resolve. It proved out that if the Security mode was set to 'Transport', I had to omit the Assembly name from the name attribute of the <service> element. In other words, it had to be exactly the same with the service name declared in the .svc file. In my case System.Web.ApplicationServices.AuthenticationService, while WebSite.System.Web.ApplicationServices.AuthenticationService was giving an error. The contract attribute had to be changed accordingly.

    What surprises me though is not why this happened but why this did not happen when the mode attribute was set to 'Nothing'. Although my application now works the way I want, I would still like to gain insight to the previous issues for the shake of gaining a better understanding. If anyone can help any further, I would be grateful.

    Thanks alot.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 9, 2015 6:07 PM