Secure and Unsecure channels in same app domain



Hello

I posted a similar message a couple days ago, but made some headway.
Here's a simpler version.

I have a server app domain that registers a secure tcpserverchannel and
an unsecure tcpserverchannel. Each channel is bound to a object.

I have a client app domain that registers a secure tcpclientchannel and
an unsecure tcpclientchannel.

If I run this scenarion in the client, it works fine

register unsecure channel
test
register secure channel
test

If I run this scenario in the client, the unsecure test call fails with
"Authentication Failure".

register secure channel
test
register unsecure channel
test - fails!

The IsSecured property of the unsecured channel is set to false, so I
don't understand why it's authorizing. I also tried using the remote
object via RegisterActivatedClientType, but it failed the same way.


All help is appreciated.

Code follows.


CLIENT


using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;

namespace ConsoleApplication5
{
class Client
{
static string server = "localhost";
static void StartUnsecure()
{
IDictionary properties = new Hashtable();
properties.Add("secure", false);
properties.Add("name", "clientUnsecure");
properties.Add("priority", 1);

TcpClientChannel clientUnsecure = new
TcpClientChannel(properties, null);
ChannelServices.RegisterChannel(clientUnsecure, false);
//ChannelServices.UnregisterChannel(clientUnsecure);
}
static void TestUnsecure()
{
System.Console.WriteLine("Test
Unsecured\n--------------------------------");
System.Console.WriteLine("IsSecured: " +
((TcpClientChannel)ChannelServices.GetChannel("clientUnsecure")).IsSecured.ToString());
SampleObject test =
(SampleObject)Activator.GetObject(typeof(SampleObject), "tcp://" +
server + ":8082/Unsecured.rem");
System.Console.WriteLine("unsecure: " +
test.GetTest().ToLongTimeString());
System.Console.WriteLine("\n");
}

static void StartSecure()
{
IDictionary propertiesSecure = new Hashtable();
propertiesSecure.Add("secure", true);
propertiesSecure.Add("name", "clientSecure");
propertiesSecure.Add("priority", 2);


TcpClientChannel clientSecure = new
TcpClientChannel(propertiesSecure, null);
ChannelServices.RegisterChannel(clientSecure, true);
//ChannelServices.UnregisterChannel(clientSecure);
}
static void TestSecure()
{
System.Console.WriteLine("Test
Secured\n--------------------------------");
System.Console.WriteLine("IsSecured: " +
((TcpClientChannel)ChannelServices.GetChannel("clientSecure")).IsSecured.ToString());
SampleObject2 testSecure =
(SampleObject2)Activator.GetObject(typeof(SampleObject2), "tcp://" +
server + ":8081/Secured.rem");
System.Console.WriteLine("secure: " +
testSecure.GetTest2().ToLongTimeString());
System.Console.WriteLine("\n");
}
static void Main(string[] args)
{
//System.Diagnostics.Debugger.Launch();

System.Console.Write("Press Enter to start.");
System.Console.ReadLine();
System.Console.WriteLine("\n\n");

if (false)
{
//this works because UNSECURE is registered first.
StartUnsecure();
TestUnsecure();

StartSecure();
TestSecure();
TestUnsecure();
}
else
{
StartSecure();
TestSecure();

StartUnsecure();
TestUnsecure();
}

System.Console.WriteLine("Press ENTER to end");
System.Console.ReadLine();

}
}
}




SERVER


using ConsoleApplication5;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;
using System.Security;


namespace Server2
{
/// <summary>
/// 8082 - Unsecure
/// 8081 - Secure
/// </summary>
public class Server
{
private static void StartUnsecure()
{
IDictionary properties = new Hashtable();
properties.Add("port", 8082);
properties.Add("secure", false);
properties.Add("name", "unsecure");
//properties.Add("authenticationMode", "None");
//properties.Add("authorizationModule",
"Server2.AuthorizationDummy,Server2");
//properties.Add("tokenImpersonationLevel", "None");
//properties.Add("impersonate", false);

// Create an instance of a channel
TcpServerChannel serverChannel = new TcpServerChannel(properties,
null);
ChannelServices.RegisterChannel(serverChannel, false);

// Register as an available service with the name HelloWorld

RemotingConfiguration.RegisterWellKnownServiceType(typeof(SampleObject),
"Unsecured.rem", WellKnownObjectMode.Singleton);
}
private static void StartSecure()
{
IDictionary properties = new Hashtable();
properties.Add("port", 8081);
properties.Add("secure", true);
properties.Add("name", "secure");
//properties.Add("authenticationMode", "IdentifyCallers");
//properties.Add("impersonate", false);

// Create an instance of a channel
TcpServerChannel serverChannel = new TcpServerChannel(properties,
null);
ChannelServices.RegisterChannel(serverChannel, true);

// Register as an available service with the name HelloWorld

RemotingConfiguration.RegisterWellKnownServiceType(typeof(SampleObject2),
"Secured.rem", WellKnownObjectMode.Singleton);
}
static void Main(string[] args)
{
StartSecure();
StartUnsecure();

Console.WriteLine("Unsecure: 8082\n Secure: 8081");
Console.WriteLine("Press the enter key to exit...");
Console.ReadLine();
}
}
}





using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication5
{
public class SampleObject : MarshalByRefObject
{
public DateTime GetTest()
{
return System.DateTime.Now;
}
public SampleObject()
{
}
}
public class SampleObject2 : MarshalByRefObject
{
public DateTime GetTest2()
{
return System.DateTime.Now;
}
public SampleObject2()
{
}
}
}

.



Relevant Pages

  • Re: Accessing secure and unsecure services from same app domain
    ... The server has 2 channels ... There's one secure server and client, ... the first channel I register is always used. ...
    (microsoft.public.dotnet.framework.remoting)
  • Registering two channels
    ... I need to register two channels but the system only seems to recognize one. ... I have a server which has two-way remoting with its clients. ... Now the server needs to act as a client to another server. ... attach a security sink on the the client side of a channel. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: computer browser service wont start
    ... I've noticed that dnsApi is sometimes one of the things that starts early before everything it needs is actually working, e.g. the TCP/IP and network stack. ... In the situations I've seen the Event Log entry from dnsApi that you report, the computer did successfully register itself later. ... This assumes that the targetted DNS server can accept Dynamic registrations and the computer doing the dynamic registration is permitted to do so. ...
    (microsoft.public.windows.server.general)
  • ASP: Get user login ID
    ... But when we register the dll on our web ... server, and call it from our ASP code, it generates an error. ... Dim lngCharsReturned As Long ...
    (microsoft.public.inetserver.iis.security)
  • Re: A record dynamic DNS registration failing depending on DHCP
    ... for clients. ... so I can assume that your server is using the default root hints. ... are only being registered in the Reverse Lookup Zone. ... recieved their IP from another DHCP server register their name under the ...
    (microsoft.public.windows.server.dns)

Loading