为我的 WCF 服务启用 SSL [英] Enable SSL for my WCF service

查看:29
本文介绍了为我的 WCF 服务启用 SSL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在开发中使用 basicHttpbinding 的 WCF 服务.

I have a WCF service that uses basicHttpbinding in development.

现在在我们想要使用 SSL 的产品中,我必须做哪些更改才能仅强制使用 SSL 连接?

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

推荐答案

MSDN 上的这个页面解释了 WCF 绑定安全性.

This page on MSDN explains WCF Binding Security.

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

BasicHttpBinding 类是主要用于互操作现有的 Web 服务,以及许多这些服务由 Internet 托管信息服务 (IIS).因此,运输安全因为这个绑定是专为与 IIS 无缝互操作网站.这是通过设置安全模式传输,然后设置客户端凭据类型.凭证类型值对应IIS 目录安全机制.下面的代码显示了模式正在设置和凭据类型设置到 Windows.你可以用这个当客户端和服务器位于同一个 Windows 域中.

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;

或者,在配置中:

<bindings>   
   <basicHttpBinding>
            <binding name="SecurityByTransport">
               <security mode="Transport">
                 <transport clientCredentialType="Windows" />
                </security>
            </binding>   
   </basicHttpBinding> 
</bindings>

要启用 ssl,无需登录,请将 clientCredentialType 设置为无".

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

安全模式的选项是:

无、传输、消息、TransportWithMessageCredential 和 TransportCredentialOnly

None, Transport, Message, TransportWithMessageCredential and TransportCredentialOnly

您可以在以下位置找到更多详细信息:http://msdn.microsoft.com/en-us/library/system.servicemodel.basichttpsecuritymode.aspx

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

这篇关于为我的 WCF 服务启用 SSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆