没有安全性的WCF

时间:2010-04-21 02:53:19

标签: wcf security xaml

我有一个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>

由于

1 个答案:

答案 0 :(得分:2)

为您提供更多信息!!

你的服务器端和客户端配置是什么? <system.serviceModel>中的任何内容都是有意义的。你使用什么绑定?

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

<强>更新

好的,使用配置,我可以指出某些事情:

<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" />
    
  • 您需要在客户端 AND 服务器上都有此<bindings>部分,并且需要从端点引用该绑定配置:

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