views:

706

answers:

1

I am trying to implement encryption for my WCF service. I am aware that there are several options out there for me to do this. I am not interested in them. I would like to use a password to regenerate repeatable RSA keys. These keys will then be used to exchanged AES keys which will be used to encrypted the actual passed data.

I think I need a custom binding to do this. I would also be interested in trying to simply add my own binding element to the NetTCP binding. Has anyone tried to either customize the existing binding, or create a completely custom binding?

Update 1

I would really take any input about creating custom bindings. I can get the encryption part up and working from there.

Update2

I have a customer binding, and a custom binding element. Right now I am implementing the override for MessageEncoder.WriteMessage. I need to know where that message is going so I can use the right encryption key. I can't seem to access this destination address.

A: 

Here are some links for you:

Custom Bindings from MSDN documentation

Kirk Evans Blog: WCF and Custom Bindings

Basically you'll do something like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="NetHttpBinding">
          <reliableSession />
          <compositeDuplex />
          <oneWay />
          <binaryMessageEncoding />
          <httpTransport />
        </binding>
      </customBinding>
    </bindings>
    <services>
      <service name="MyService">
        <endpoint
          address="http://localhost:8001/myService/"
          binding="customBinding"
          bindingConfiguration="NetHttpBinding"
          contract="MyServiceContract"
          name="HttpBinding" />
      </service>
    </services>
  </system.serviceModel>
</configuration>

That first link should help you the most. Good luck!

Terry Donaghe