C #: Restrict remote .Net connection only to connect to localhost

I use .Net Remoting to handle in-process communication between the main service and numerous (sometimes 50+) instances of a small client library. From a security point of view, it is imperative that the service accepts only connections from the local machine, and no one else - so far I can not find any information on how to do this, and MSDN documents do not help much.

Preferably, I would like to maintain connections tied to the local host, so as not to set user firewall warnings ... but this is not required.

Thank you for your help!

Tom

+3
source share
2 answers

In the end, I came across this while studying the IpcChannel documentation.

The problem with IpcChannel is that Windows Named Pipes do not work correctly in UAC when the client works as a process with low integrity. Unfortunately, since I'm working on a plugin and not with a complete application, the low-level host module of the plugin means calling many Win32 APIs, including some new Vista-specific ones, and programmatically setting application ACL tokens, which is something what I really don't want to do.

Fortunately, some of the overloaded RegisterChannel () forms allow you to specify parameters in the System.Collections.IDictionary Hashtable object, some of which are related to security and handling of remote connections. More details here:

http://msdn.microsoft.com/en-us/library/bb187434%28VS.85%29.aspx

TcpChannel , . !

            System.Collections.IDictionary sProperties = new System.Collections.Hashtable();

        sProperties["port"] = SERVER_PORT;
        sProperties["authorizedGroup"] = "INTERACTIVE";
        sProperties["rejectRemoteRequests"] = true;

        BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();

        TcpServerChannel channel = new TcpServerChannel(sProperties, serverProvider);   
        ChannelServices.RegisterChannel(channel, false);

, , , .

+4

IpcChannel, .NET 2.0+. TCP.

+2

Source: https://habr.com/ru/post/1719563/


All Articles