【问题标题】:WCF Server Configuration for Windows Authentication for wsHttpBinding用于 wsHttpBinding 的 Windows 身份验证的 WCF 服务器配置
【发布时间】:2018-11-26 06:08:15
【问题描述】:

我必须在服务器上托管的服务上实施“Windows 身份验证”。
我正在使用“wsHttpBinding”。其中“消息”是默认的安全模式。

以下是我的服务器配置:

web.config

<authentication mode="Windows" />

    <services>
          <service name="WCFWsHttpBindingHttps.Service1" behaviorConfiguration="WCFWsHttpBindingHttps.Service1Behavior">
            <!-- Service Endpoints -->
            <endpoint address="" binding="wsHttpBinding" contract="WCFWsHttpBindingHttps.IService1">
            </endpoint>
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
          </service>
        </services>
    <behaviors>
          <serviceBehaviors>
            <behavior name="WCFWsHttpBindingHttps.Service1Behavior">
              <serviceMetadata httpGetEnabled="true" />
              <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
          </serviceBehaviors>
        </behaviors>

下面是我的 IIS 配置:

尽管进行了所有配置,但我无法访问我的服务。 任何人都可以通知我在哪里出错或我错过了任何配置。

我在尝试访问我的服务时收到以下错误。

【问题讨论】:

  • 你应该定义一个安全模式TransportCredentialOnly&lt;transport clientCredentialType="Windows" /&gt;的绑定
  • @Aria 在 wsHttpBinding 我们没有“TransportCredentialOnly”。我需要使用“wsHttpBinding”和安全模式作为“消息”来实现 Windows 身份验证。

标签: wcf iis windows-authentication wshttpbinding


【解决方案1】:

当您使用wsHttpBinding 时,安全模式必须为Transport 才能在IIS 上使用Windows 身份验证,而另一端的消费者需要配置服务器证书。

如果您使用其他安全模式,您将遇到以下异常:

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

所以你必须wsHttpBinding如下:

<wsHttpBinding>
    <binding>
      <security mode="Transport">
        <transport clientCredentialType="Windows"/>
      </security>
    </binding>
</wsHttpBinding>

如果您使用Message 安全模式,这意味着您将通过非安全传输方式发送加密消息,并且要对消息进行加密,您必须使用自己的证书,另一方面您也有配置客户端验证证书的方式,确保消费者协商到正确的服务。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-08-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多