Search code examples
c#.netwcfsecurityservicecontract

Using WCF, how can I make sure only trusted assemblies call my service?


I have a simple service contract, defined as:

[ServiceContact]
public interface IEcho
{
    [OperationContract]
    void Hello(string value);
}

which is implemented in a local WCF service (accessed through a net.pipe:// address).

I need to know who is calling the service.

Basically, I need to reject the calls to IHello.Echo made from any assembly not signed by me, for security reasons. The Hello method should not be available to untrusted callers.

I vaguely remember that in the old .NET 1 remoting days, we could walk the stack and check the identity of the callers. But how can I do this with WCF?


Solution

  • I've come across other questions along the same lines:

    and apparently, there is no secure way of making sure the sender of the message is indeed a specific strongly signed assembly. There is always some way a malicious assembly could spoof its identity.

    In short, the answer is: it is impossible.