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

Tim*_*Tim 19 ssl wcf basichttpbinding wcf-binding wcf-security

是否可以仅使用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 purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
      <exceptionShielding/>
    </behavior>
  </serviceBehaviors>
</behaviors>
Run Code Online (Sandbox Code Playgroud)

我尝试了两种带有两种不同错误的绑定:

1 - IIS错误:'无法通过绑定BasicHttpBinding找到与端点的方案http匹配的基址.注册的基地址方案是[https].

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

</bindings>
Run Code Online (Sandbox Code Playgroud)

2 - IIS错误:此服务的安全设置需要"匿名"身份验证,但未为承载此服务的IIS应用程序启用.

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

</bindings>
Run Code Online (Sandbox Code Playgroud)

有人知道如何正确配置吗?(如果可能的话?)

Tim*_*Tim 24

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

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

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

WCF安全性:因为绑定只是一个BasicHttpBinding,所以该服务不需要任何有效的东西.IIS负责此事.

服务的绑定配置:

<bindings>
  <basicHttpBinding>
     <binding>
        <security mode="Transport">
           <transport clientCredentialType="Basic" />
        </security>
     </binding>
  </basicHttpBinding>
Run Code Online (Sandbox Code Playgroud)

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

删除:

<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
Run Code Online (Sandbox Code Playgroud)

  • 感谢您对这篇文章."在IIS中设置应用程序的权限"是什么意思? (2认同)
  • Windows用户帐户应该长到什么组?需要设置哪些权限? (2认同)
  • 为什么删除`<endpoint address ="mex"binding ="mexHttpsBinding"contract ="IMetadataExchange"/>`? (2认同)