【问题标题】:How can I use WCF with the basichttpbinding only , SSL and Basic Authentication in IIS?如何在 IIS 中将 WCF 与 basichttpbinding only 、 SSL 和 Basic Authentication 一起使用?
【发布时间】:2011-02-23 16:41:51
【问题描述】:

是否可以仅使用BasicHttpBinding-binding 在 IIS 中设置具有 SSL 和基本身份验证的 WCF 服务?
(我不能用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>

我尝试了 2 种类型的 绑定,但出现了两个不同的错误:

  • 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>
    

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

【问题讨论】:

    标签: wcf ssl wcf-binding wcf-security basichttpbinding


    【解决方案1】:

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

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

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

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

    服务的绑定配置:

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

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

    已删除:

    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
    

    【讨论】:

    • 感谢您的这篇文章。 “在 IIS 中设置应用程序的权限”是什么意思?
    • Windows 用户帐户应该长到哪些组?需要设置哪些权限?
    • 为什么要删除&lt;endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/&gt;
    • 您可以查看 microsoft 页面以使用 SSL 设置,包括在 IIS 上设置权限。 docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/….
    猜你喜欢
    • 2017-06-12
    • 2016-02-12
    • 1970-01-01
    • 2012-04-15
    • 2020-09-17
    • 1970-01-01
    • 1970-01-01
    • 2016-05-16
    • 1970-01-01
    相关资源
    最近更新 更多