Search code examples
wcf-securitynettcpbinding

Creating a custom binding in WCF from an existing nettcpbinding


Can anyone tell me how to create a custom binding that reproduces the exact same behavior from the following in WCF?

<netTcpBinding>
        <binding name="SecureTcp" >
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="Certificate" />
            <message clientCredentialType="UserName" />
          </security>
        </binding>
      </netTcpBinding>

All of the googled solutions that I've found don't seem to be working for one reason or another. I've found a lot of solutions regarding httpTransport, but very few regarding nettcptransport.

The above configuration is currently working, but I need to modify the maxClockSkew, and the only way to accomplish this is with a custom binding.

Thanks in advance, Brian


Solution

  • Well, here's what I was able to come up with. They key was the authenticationMode in the secureConversationBoostrap section:

    <binding name="CustomSecureTcp">
        <transactionFlow  />
        <security authenticationMode="SecureConversation"requireSecurityContextCancellation="true">
          <secureConversationBootstrap
            authenticationMode="UserNameOverTransport">
          </secureConversationBootstrap>
        </security>
        <binaryMessageEncoding/>
        <sslStreamSecurity requireClientCertificate="false" />
        <tcpTransport/>
      </binding>
     </customBinding>
    

    EDIT: I'm pretty sure that the 'transactionProtocol="OleTransactions"' was unnecessary