相关疑难解决方法(0)

如何在IIS中仅使用WCF进行basichttpbinding,SSL和基本身份验证?

是否可以仅使用BasicHttpBinding绑定在IIS中使用SSL和基本身份验证设置WCF服务?(我不能使用wsHttpBinding绑定)

该站点托管在IIS 7上,并设置了以下身份验证:

   - Anonymous access: off
   - Basic authentication: on
   - Integrated Windows authentication: off !!
Run Code Online (Sandbox Code Playgroud)

服务配置:

<services>
  <service name="NameSpace.SomeService">
    <host>
      <baseAddresses>
        <add baseAddress="https://hostname/SomeService/" />
      </baseAddresses>

    </host>
    <!-- Service Endpoints -->
    <endpoint address="" binding="basicHttpBinding"
              bindingNamespace="http://hostname/SomeMethodName/1"
              contract="NameSpace.ISomeInterfaceService"
              name="Default"
                      />
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
      <serviceMetadata httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging …
Run Code Online (Sandbox Code Playgroud)

ssl wcf basichttpbinding wcf-binding wcf-security

19
推荐指数
1
解决办法
5万
查看次数

使用支持流式传输的basicHttpBinding保护WCF服务

我的问题是关于安全访问WCF服务的最佳(也称为"最不痛苦")方式,该服务仅暴露给我们公司的内部用户.目标是确保只通过我们每个用户安装的单个Windows窗体应用程序访问该服务.调用该服务时,我希望该服务能够验证它是否已从允许的应用程序中调用.

要保护的服务使用basicHttpBinding,它支持流式传输,因此我相信我仅限于传输级安全性.

以下是我服务的配置文件中的部分<bindings><services>部分的简化版本.

<bindings>
  <basicHttpBinding>
    <binding name="Service1Binding" transferMode="Streamed"/>    
  </basicHttpBinding>
</bindings>

<services>
    <service name="WCFServiceSecurity.Service1" 
        behaviorConfiguration="WCFServiceSecurity.Service1Behavior">
        <endpoint address=""
            binding="basicHttpBinding"
            contract="WCFServiceSecurity.IService1"
            bindingConfiguration="Service1Binding"/>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    </service>
</services>
Run Code Online (Sandbox Code Playgroud)

任何人都可以提供一些细节,说明为了实现此服务的安全性我需要采取什么行动?

注意:我是WCF的新手并且根本不熟悉安全性,所以如果我没有提供足够的详细信息,请告诉我.


更新:

正如marc_s建议的那样,我想使用某种用户名/密码机制来保护WCF服务.这为答案提供了更多的方向,但我仍然有点模糊如何实际做到这一点.

因为我的服务需要启用流媒体,所以我必须使用basicHttpBinding和传输级安全性(对吗?); 此外,我的服务中包含的方法只能接受Stream对象.

考虑到这些限制以及我使用用户名/密码验证的偏好...

  • 我应该如何修改服务的配置文件以强制提供用户名/密码凭据?
  • 我的服务如何验证提供的凭据?
  • 我的客户端应用程序在拨打电话时如何通过服务凭证?
  • 这是否需要使用SSL,如果是这样,所有客户端机器是否也需要证书?

更新:

在解释了我一直在为我的老板提供这项服务所遇到的麻烦之后,我获准尝试Windows身份验证路由.可悲的是,我没有幸运用我的流媒体服务(argh)实现这种类型的身份验证.进行适当的更改后(如概述这里 -唯一的例外是我的transferMode="Streamed")和访问我的服务,我提交了以下错误:

HTTP请求流不能与HTTP身份验证结合使用.禁用请求流或指定匿名HTTP身份验证.

然后我偶然发现了以下引用,这提供了一些澄清:

你不能做运输认证.与流媒体.如果必须使用HTTP请求流,则必须在没有安全性的情况下运行.

安全的工作方式是:

WCF客户端向服务器发出http请求.

服务器回答说:"你没有被授权,给我发一个基本/摘要/等证书."

客户端获取该响应并使用所附的凭据重新发送其消息.

现在,服务器获取消息,验证凭据,然后继续.请求Streaming不适用于该安全模式.如果确实如此,它会非常慢,因为客户端会发送整个流,从服务器获取未经授权的消息,然后它必须使用凭据重新发送整个流.

所以现在我正在寻找意见,您如何保护启用流媒体的WCF服务?如前所述,某种用户名/密码机制将是首选.在这个盒子外面随意思考......

非常感谢任何帮助!

wcf wcf-security

12
推荐指数
1
解决办法
3万
查看次数

标签 统计

wcf ×2

wcf-security ×2

basichttpbinding ×1

ssl ×1

wcf-binding ×1