重现问题:使用客户端身份验证方案禁止 http 请求 'anonymous'

Reproduce Issue: The http request was forbidden with client authentication scheme 'anonymous'

我想重现 wcf 问题:客户端身份验证方案禁止 http 请求 'anonymous'

我们在我们的产品中使用 wcf 服务,我们将 wcf 服务托管为 Windows 服务(Self-Host 服务)并且正在使用此 wcf 服务通过小型 windows 客户端应用程序

我们的环境运行良好。但是,我们的一位客户报告说,他们在连接 客户端应用程序时收到错误消息“HTTP 请求被客户端身份验证方案 'anonymous' 禁止” 来自远程客户端计算机。

在这里,我的问题是,谁能帮我在我们的环境中重新生成这个问题,以便我们可以完美修复。

ServiceApp.config

<bindings>
      <wsHttpBinding>
        <binding name="MyBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="100" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
          <reliableSession inactivityTimeout="24.00:00:00" />
          <security mode="None">
            <message clientCredentialType="None" />
          </security>

        </binding>
      </wsHttpBinding>
    </bindings>
    <services>
      <service behaviorConfiguration="MyBehaviour" name="WcfServer.CalculatorService">
        <endpoint address="http://localhost:7000/Test" behaviorConfiguration="MyEndPointBehavior"
          binding="wsHttpBinding"  bindingConfiguration="MyBinding"
          name="EndPt_Service" contract="WcfServer.ICalculator"/>
      </service>
    </services>

clientapp.config

<bindings>
      <wsHttpBinding>
        <binding name="CalBinding" maxBufferPoolSize="2147483647"  maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="100" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="2147483647" />
          <reliableSession inactivityTimeout="24.00:00:00" />
          <security mode="None">
            <message clientCredentialType="None" />
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://RemoteServerName:7000/Test" behaviorConfiguration="CalEndPointBehavior"
        binding="wsHttpBinding" contract="WcfServer.ICalculator"
         name="EndPt_Calc" bindingConfiguration="CalBinding"/>
    </client>

我在msdn论坛上找到的,希望对你有帮助:

由于您为 WsHttpBinding 指定了安全模式= none,当它向 WCF 服务发出请求时,服务将尝试使用 Aninymous 凭据对客户端进行身份验证,但是对于不同的域,这将不起作用,所以尝试使用 X509 证书。

所以尝试在两个不同的域之间建立连接。