【问题标题】:wsHTTPBinding authentication errorwsHTTPBinding 认证错误
【发布时间】:2014-11-10 20:07:27
【问题描述】:

我想在 Web 服务上实现 wsHTTPBinding,但我不断收到此错误: “调用者未经服务验证”。我看过很多关于这个主题的帖子,但它们要么不能解决我的问题/与我的配置无关,要么“答案”是使用 basicHTTPBinding。 该服务托管在具有自己的 ssl 证书的安全网站的根文件夹中。我希望我可以使用该证书来合理地保护 SOAP 消息,这就是我想坚持使用 wsHTTP 的原因。但是,我尝试修改各种配置——甚至将身份验证模式设置为“无”以使其正常工作——但每次我都遇到同样的错误。 有谁知道我如何修改 web.config 设置以使 wsHTTPBinding 使用现有的 ssl 证书工作?

Web.config

<?xml version="1.0"?>
  <configuration>
    <appSettings/>
      <connectionStrings/>
        <system.web>


          <trust level="Full"></trust>

          <compilation debug="true" strict="false" explicit="true" targetFramework="4.0"/>

          </system.web>

          <system.serviceModel>
            <services>
              <service behaviorConfiguration="xxxService1.xxx1Behavior" name="xxxService1.xxx1">
                <endpoint address="" 
                binding="basicHttpBinding" 
                contract="xxxService1.Ixxx1"
                bindingConfiguration="secureHttpBinding"
                >
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
              </service>
            </services>
          <bindings>
        <basicHttpBinding>
          <binding name="secureHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
    </binding>
  </basicHttpBinding>
</bindings>
<behaviors>
  <serviceBehaviors>
    <behavior name="xxxService1.Service1Behavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
    <behavior name="xxxService1.xxx1Behavior">
      <serviceMetadata httpGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
</system.serviceModel>

<system.webServer>
  <modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>

</configuration>

App.config

<?xml version="1.0" encoding="utf-8" ?>
  <configuration>
    <startup useLegacyV2RuntimeActivationPolicy="true">

    <requiredRuntime version="v4.0.20506"/>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
     </startup>
    <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="secureHttpBinding">
          <security mode="Transport">
          <transport clientCredentialType="None"/>
          </security>
        </binding>
     </basicHttpBinding>

    </bindings>
    <client>

    <endpoint address="https://111.111.111.111/xxxAPI/xxx1.svc" 
            binding="basicHttpBinding"

            contract="TestingxxxService1.Ixxx1"
      name="BasicHttpBinding_Ixxx1"
            bindingConfiguration="secureHttpBinding" />
    </client>
</system.serviceModel>
</configuration>

【问题讨论】:

    标签: .net wcf ssl wshttpbinding


    【解决方案1】:

    您需要发布您的客户端和服务器配置。配置取决于您需要用于身份验证的凭据。要通过 HTTP 绑定(BasicHttpBinding 或 WsHttpBinding)使用 SSL,安全模式将为 Transport 或 TransportWithMessageCredential。为什么需要 WsHttpBinding?

    这里有很多不同的配置选项: http://msdn.microsoft.com/en-us/library/ms789011%28v=vs.110%29.aspx

    一个例子:

    <wsHttpBinding>
        <binding name="WsHttpBinding_ICalculator">
            <security mode="TransportWithMessageCredential" >
               <message clientCredentialType="UserName" />
            </security>
        </binding>
    </wsHttpBinding>
    

    【讨论】:

    • 我在发布后发现是的,你是对的,我不需要 wsHTTP。我不认为 basicHTTP 会支持 ssl。我已经发布了我编辑的 web 和 app.config,但现在我得到'无法为 SSL/TLS 安全通道建立信任关系授权 '...
    • 这是自签名证书吗?
    【解决方案2】:

    这里的问题是我正在我们尚未迁移到的新站点上测试服务。因此,该站点仅由 IP 地址而非域识别。来自旧站点的 SSL 证书(我在我们的 Web 托管服务端口拥有技术到新站点)拒绝了通信,因为显然该请求是针对来自它无法识别的 IP 的资源。我通过将服务转移到现有站点进行测试来“解决”问题。 一个小提示,如果您以这种方式访问​​ Web 服务,则必须记住在 IIS 中启用 SSL。

    查看我的配置文件中的端点元素: 端点地址="https://111.111.111.111/xxxAPI/xxx1.svc"

    它必须是: 端点地址="https://www.mysite.com/xxxAPI/xxx1.svc"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-16
      • 2012-03-14
      相关资源
      最近更新 更多