C# 如何使我的NET.TCP WCF服务处理安全和不安全的通信

C# 如何使我的NET.TCP WCF服务处理安全和不安全的通信,c#,wcf,security,tcp,C#,Wcf,Security,Tcp,我的WCF服务需要处理以下事项: 1服务 常规TCP端点 安全的customUsernamePassword端点 安全Windows端点 system.serviceModel部分如下所示: <system.serviceModel> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> <behaviors> <service

我的WCF服务需要处理以下事项:

  • 1服务
  • 常规TCP端点
  • 安全的customUsernamePassword端点
  • 安全Windows端点
system.serviceModel部分如下所示:

    <system.serviceModel>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

        <behaviors>
   <serviceBehaviors>
    <behavior name="AppClientService.CustomValidator_Behavior">
     <dataContractSerializer maxItemsInObjectGraph="2147483647" />
     <serviceDebug includeExceptionDetailInFaults="true" />
     <serviceMetadata httpGetEnabled="true" />

     <serviceCredentials>
      <clientCertificate>
       <authentication certificateValidationMode="PeerOrChainTrust" />
      </clientCertificate>
      <serviceCertificate findValue="MyService" storeLocation="LocalMachine"
       storeName="Root" x509FindType="FindBySubjectName" />
      <userNameAuthentication userNamePasswordValidationMode="Custom"
       customUserNamePasswordValidatorType="App.ServiceImplementation.CustomUsernamePasswordValidator, App.ServiceImplementation" />
     </serviceCredentials>

     <serviceAuthorization principalPermissionMode="Custom" serviceAuthorizationManagerType="App.ServiceImplementation.CustomServiceAuthorizationManager, App.ServiceImplementation">
      <authorizationPolicies>
       <add policyType="App.ServiceImplementation.CustomAuthorizationPolicy, App.ServiceImplementation" />
      </authorizationPolicies>
     </serviceAuthorization>
    </behavior>
   </serviceBehaviors>
  </behaviors>
        <services>
            <service behaviorConfiguration="AppClientService.CustomValidator_Behavior" name="App.ServiceImplementation.AppClientService">
        <endpoint binding="netTcpBinding" bindingConfiguration="netTcpRegular" address="Regular" bindingNamespace="http://App.ServiceContracts/2007/11" contract="App.ServiceContracts.IAppClientService" />
                <endpoint binding="netTcpBinding" bindingConfiguration="netTcpUserNameMessageSecurity" address="UserName" bindingNamespace="http://App.ServiceContracts/2007/11" contract="App.ServiceContracts.IAppClientService" />
                <endpoint binding="netTcpBinding" bindingConfiguration="netTcpWindowMessageSecurity" address="Windows" bindingNamespace="http://App.ServiceContracts/2007/11" contract="App.ServiceContracts.IAppClientService" />
        <endpoint address="httpMex" binding="mexHttpBinding" contract="IMetadataExchange" />
                <endpoint address="tcpMex" binding="mexTcpBinding" contract="IMetadataExchange" />
            </service>
        </services>
        <bindings>
            <!-- NET.TCP -->
            <netTcpBinding>
                <binding name="netTcpUserNameMessageSecurity" portSharingEnabled="True" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="01:00:00" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
                    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false" />
                    <security mode="TransportWithMessageCredential">
                        <transport clientCredentialType="Windows" />
                        <message clientCredentialType="UserName" />
                    </security>
                </binding>
                <binding name="netTcpWindowMessageSecurity" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
                    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
                    <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false" />
                    <security mode="Message">
                        <message clientCredentialType="Windows" />
                    </security>
                </binding>
        <binding name="netTcpRegular" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="01:00:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
            </netTcpBinding>
        </bindings>
    </system.serviceModel>

这对Windows登录和CustomUsername密码登录很好,但我不知道如何让常规(不安全)端点工作

求教


BestReleases

您需要将安全模式设置为无