22

是否可以仅使用 IIS 在 IIS 中设置具有 SSL 和基本身份验证的 WCF 服务BasicHttpBinding-binding
(我不能使用wsHttpBinding-binding

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

  • 匿名访问:关闭
  • 基本认证:
  • 集成 Windows 身份验证:关闭

服务配置:

<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 purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <exceptionShielding/>
    </behavior>
  </serviceBehaviors>
</behaviors>

我尝试了两种类型的绑定,但有两种不同的错误:

  • 1. IIS错误:

    '找不到与绑定 BasicHttpBinding 的端点的方案 http 匹配的基地址。注册的基地址方案是 [https]。

    <bindings>
       <basicHttpBinding>
         <binding>
           <security mode="TransportCredentialOnly">
             <transport clientCredentialType="Basic"/>
           </security>
         </binding>
       </basicHttpBinding>
     </bindings>
    
  • 2. IIS错误:

    此服务的安全设置需要“匿名”身份验证,但托管此服务的 IIS 应用程序未启用它。

     <bindings>
       <basicHttpBinding>
         <binding>
           <security mode="Transport">
             <transport clientCredentialType="Basic"/>
           </security>
         </binding>
       </basicHttpBinding>
      </bindings>
    

有谁知道如何正确配置它?(如果可能吗?

4

1 回答 1

25

经过一番挖掘并向几位同事提出一些问题,我们终于解决了这个问题。

重要的是要了解在这种情况下安全性有两个方面。IIS 安全性和 WCF 安全性。

IIS 安全性:启用 SSL 并启用基本身份验证。禁用匿名身份验证。(当然,创建一个 windows 帐户/组并在 IIS 中设置应用程序的权限。)

WCF 安全性:因为绑定只是一个 BasicHttpBinding,所以服务不需要验证任何内容。IIS 对此负责。

服务的绑定配置:

<bindings>
  <basicHttpBinding>
     <binding>
        <security mode="Transport">
           <transport clientCredentialType="Basic" />
        </security>
     </binding>
  </basicHttpBinding>

最后,为了解决第一个错误,我们删除了 mex 端点。此端点需要 HTTP 绑定。

删除:

<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
于 2010-05-28T06:32:53.347 回答