Enable SSL for my WCF service

后端 未结 3 1495
北荒
北荒 2020-11-28 22:01

I have a WCF service that uses basicHttpbinding in development.

Now in product we want to use SSL, what changes do I have to make to force SSL connections only?

3条回答
  •  一个人的身影
    2020-11-28 22:33

    I think that if under your "bindings" where you have , if you'd change it to be , you would be ok.

    this is a copy of a codebase that I'm working on that I did that in-code, and it appears to be working. I get the WSDL at least when i hit the service, if that helps at all :)

    BasicHttpBinding basicBinding = new BasicHttpBinding();
    if (RegistryConnectionStringFactory.UseSslForCommunications)
    {
         basicBinding.Security.Mode = BasicHttpSecurityMode.TransportWithMessageCredential;
         basicBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
    }
    else
    {
         basicBinding.Security.Mode = BasicHttpSecurityMode.None;
         basicBinding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
    }
    

提交回复
热议问题