【问题标题】:WCF with No security没有安全性的 WCF
【发布时间】:2011-02-10 10:06:43
【问题描述】:

我有一个 WCF 服务设置,我可以使用和使用它,但只能在同一台机器上使用。我希望在多台计算机上运行它,我对安全性并不在意。但是,当我将(客户端)安全设置为 = none 时,我得到一个 InvalidOperationException:

服务证书不是 为目标提供 'http://xxx.xxx.xxx.xxx:8731/Design_Time_Addresses/WcfServiceLibrary/ManagementService/'。 在中指定服务证书 ClientCredentials。

所以我只剩下:

<security mode="Message">
    <message clientCredentialType="None" negotiateServiceCredential="false"
        algorithmSuite="Default" />
</security> 

但这给了我另一个 InvalidOperationException:

服务证书不是 为目标提供 'http://xxx.xxx.xxx.xxx:8731/Design_Time_Addresses/WcfServiceLibrary/ManagementService/'。 在中指定服务证书 ClientCredentials。

如果安全性关闭,为什么我必须提供证书?

更新:

服务器应用配置:

<system.serviceModel>
    <services>
      <service name="Server.WcfServiceLibrary.ManagementService" behaviorConfiguration="Server.WcfServiceLibrary.ManagementServiceBehavior">
        <host>
          <baseAddresses>
            <add baseAddress = "http://localhost:8731/Design_Time_Addresses/WcfServiceLibrary/ManagementService/" />
          </baseAddresses>
        </host>
        <endpoint address ="" binding="wsDualHttpBinding" contract="Server.WcfServiceLibrary.IManagementService"
                  bindingConfiguration="WSDualHttpBinding_IManagementService">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
      </service>
    </services>
      <bindings>
          <wsDualHttpBinding>
              <binding name="WSDualHttpBinding_IManagementService" closeTimeout="00:01:00"
                  openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:00:10"
                  bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                  messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                  <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                  <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                  <security mode="None" />
              </binding>
          </wsDualHttpBinding>
      </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Server.WcfServiceLibrary.ManagementServiceBehavior">
          <serviceMetadata httpGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>

客户端应用配置:

<system.serviceModel>
        <bindings>
            <wsDualHttpBinding>
                <binding name="WSDualHttpBinding_IManagementService" closeTimeout="00:01:00"
                    openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                    bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                    maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                    messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                    <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                        maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    <reliableSession ordered="true" inactivityTimeout="00:10:00" />
                    <security mode="None" />
                </binding>
            </wsDualHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://xxx:8731/Design_Time_Addresses/WcfServiceLibrary/ManagementService/"
                binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IManagementService"
                contract="ServiceReference.IManagementService">
                <!--name="WSDualHttpBinding_IManagementService">-->
                <identity>
                    <dns value="localhost" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>

谢谢

【问题讨论】:

    标签: wcf security xaml


    【解决方案1】:

    为您提供更多信息!

    您的服务器端和客户端配置是什么? &lt;system.serviceModel&gt; 中的任何内容都很有趣。你用的是什么绑定?

    例如:如果您将客户端安全设置为无,您必须在服务器端执行相同操作 - 这些设置需要匹配!

    更新:

    好的,通过配置,我可以指出一些事情:

    <bindings>
       <wsDualHttpBinding>
          <binding name="WSDualHttpBinding_IManagementService" ......>
              <readerQuotas .... />
              <reliableSession ordered="true" inactivityTimeout="00:10:00" />
              <security mode="Message">
                  <message clientCredentialType="Windows" 
                           negotiateServiceCredential="true"
                           algorithmSuite="Default" />
              </security>
           </binding>
        </wsDualHttpBinding>
    </bindings>
    

    问题:

    • 你真的需要wsDualHttpBinding吗?这是明智的选择吗?
    • 如果你不想要任何安全,你需要使用:

      <security mode="None" />
      
    • 您需要在客户端服务器上都有此&lt;bindings&gt; 部分,并且您需要从端点引用该绑定配置:

      <endpoint 
           address ="" 
           binding="wsDualHttpBinding" 
           bindingConfiguration="WSDualHttpBinding_IManagementService"
           contract="Server.WcfServiceLibrary.ICheckoutService">
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
      

    【讨论】:

    • 好的,谢谢,是的,双 http 绑定是有原因的,但 atm 我不记得为什么了!是的,我知道安全性 = 无。谢谢,如果它在 10 分钟内工作,我会更新! :)
    • 目前我可以配置对我的服务器的服务引用但是当我运行时我只是得到一个超时:(有什么想法吗?
    • 嗯,wsDualHttpBinding 是一种双向绑定——服务器期望有一个回调契约来回调客户端。如果你真的不需要这个 - 摆脱它!先试试basicHttpBinding——这是最基本、最简单的绑定。如果这可行,并且您需要更多的打击,请转到 wsHttpBinding(或 netTcpBinding,如果您在公司中,则在防火墙后设置)
    • Spanks.. 这是绑定!我已更改为 wsHttp,因为我们有该设置!非常感谢:p
    猜你喜欢
    • 1970-01-01
    • 2011-06-13
    • 2010-09-16
    • 1970-01-01
    • 1970-01-01
    • 2011-10-18
    • 1970-01-01
    • 1970-01-01
    • 2012-08-08
    相关资源
    最近更新 更多