Enable SSL for my WCF service

后端 未结 3 1494
北荒
北荒 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:27

    This page on MSDN explains WCF Binding Security.

    http://msdn.microsoft.com/en-us/library/ms729700.aspx

    The BasicHttpBinding class is primarily used to interoperate with existing Web services, and many of those services are hosted by Internet Information Services (IIS). Consequently, the transport security for this binding is designed for seamless interoperation with IIS sites. This is done by setting the security mode to Transport and then setting the client credential type. The credential type values correspond to IIS directory security mechanisms. The following code shows the mode being set and the credential type set to Windows. You can use this configuration when both client and server are on the same Windows domain.

    C#

    BasicHttpBinding b = new BasicHttpBinding();
    b.Security.Mode = BasicHttpSecurityMode.Transport ;
    b.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
    

    Or, in configuration:

       
       
                
                   
                     
                    
                   
        
    
    

    To enable ssl, without a login, set clientCredentialType to "None".

    Options for security mode are:

    None, Transport, Message, TransportWithMessageCredential and TransportCredentialOnly

    You can find more details at: http://msdn.microsoft.com/en-us/library/system.servicemodel.basichttpsecuritymode.aspx

提交回复
热议问题