Re: Accessing secure and unsecure services from same app domain



Hello

That's what it's doing (perhaps incorrectly). The server has 2 channels
open on 8080 and 8081. The client opens 2 channels on 8080 and 8081.
However, it still doesn't work. If one is secure, I can't access the
other unsecure.

Thanks for your help.




Shailen Sukul wrote:
You could publish the same object to 2 diff urls that use 2 diff channels.
Then you could specify the url to use, hence the channel when retrieving
your object.


--
With Regards
Shailen Sukul
.Net Architect
(MCPD: Ent Apps, MCSD.Net MCSD MCAD)
Ashlen Consulting Services
http://www.ashlen.net.au
<jay@xxxxxxxxxxxxxxx> wrote in message
news:1166557552.385049.173430@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
.NET 2.0

Hello

I'm trying to get up to speed with remoting.
I created a test app that has two servers and two clients.
There's one secure server and client, and one unsecure server and
client.
When I create the clients, the first channel I register is always used.
So, if I register the UNSECURE client first, then I can't call the
SECURE service, and vice-versa. An AUTHORIZATION exception is thrown.
Is there a way to specify which channel to use when making a remoting
call? Both channels are registered, but it always goes to the first one
regardless of the priority.

Thanks in advance for your help.




SERVER TEST CODE

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;

namespace Server2
{
/// <summary>
/// 8080 - Unsecure
/// 8081
/// </summary>
class Program
{
private static void StartUnsecure()
{
IDictionary properties = new Hashtable();
properties.Add("port", 8080);
properties.Add("secure", false);
properties.Add("name", "unsecure");
//properties.Add("impersonate", false);

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


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("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)
{
StartUnsecure();
StartSecure();

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





CLIENT TEST CODE

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 Program
{
static void Main(string[] args)
{
System.Console.Write("Press Enter to start.");
System.Console.ReadLine();



#region Secure Client
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, false);
SampleObject2 testSecure =
(SampleObject2)Activator.GetObject(typeof(SampleObject2),
"tcp://127.0.0.1:8081/Secured.rem");
System.Console.WriteLine("secure: " +
testSecure.GetTest2().ToLongTimeString());
//ChannelServices.UnregisterChannel(clientSecure);
#endregion




#region Unsecure Client

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);
SampleObject test =
(SampleObject)Activator.GetObject(typeof(SampleObject),
"tcp://127.0.0.1:8080/Unsecured.rem");
System.Console.WriteLine("unsecure: " +
test.GetTest().ToLongTimeString());
//ChannelServices.UnregisterChannel(clientUnsecure);
#endregion





System.Console.WriteLine("Press ENTER to end");
System.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

  • Remoting, events and custom encryption channel sinks
    ... - a server app hosts the remotable device service ... - the client app connects to a remote device service which is hosted by the ... The client app instantiates a tcp channel with a given port number because ...
    (microsoft.public.dotnet.framework.remoting)
  • RE: Problems with security requirements in Windows WorkGroups.
    ... "A remote side security requirement was not fulfilled during authentication. ... small chat application between a client and a server ... When I try to use the TCP channel I get the error (with NO inner exception ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: .Net Remoting TCP or HTTP?
    ... John's given a good description of why you would pick either the TCP or HTTP ... The reason is that, when the server needs to notify the client of the event, ... In the TCP case, this means using a bi-directional channel, so that requests ...
    (microsoft.public.dotnet.framework)
  • Re: .Net Remoting TCP or HTTP?
    ... John's given a good description of why you would pick either the TCP or HTTP ... The reason is that, when the server needs to notify the client of the event, ... In the TCP case, this means using a bi-directional channel, so that requests ...
    (microsoft.public.dotnet.framework.remoting)
  • RogerWilco: new funny bugs
    ... versus server and client (channel broadcast) ... RogerWilco is a voice chat application running on Windows and MacOS ...
    (Full-Disclosure)

Loading