When unsecure client connects to the secure server, the server will crash due to an exception thrown by server channel encryption sinks. Here is the example:
``` c#
// Compile: csc test.cs /r:Zyan.Communication.dll
using System;
using System.Collections;
using System.Linq;
using Zyan.Communication;
using Zyan.Communication.Protocols.Tcp;
using Zyan.Communication.Security;
struct Program
{
static void Main(string[] args)
{
if (args.Any())
RunClient(args);
else
RunServer();
}
static void RunServer()
{
var port = 1234;
var auth = new NullAuthenticationProvider();
var protocol = new TcpDuplexServerProtocolSetup(port, auth, true);
using (var host = new ZyanComponentHost("SecureServer", protocol))
{
Console.WriteLine("Server started. Press ENTER to quit");
Console.ReadLine();
}
}
static void RunClient(string[] args)
{
// insecure client
var clientProtocol = new TcpDuplexClientProtocolSetup(false);
using (var conn1 = new ZyanConnection("tcpex://localhost:1234/SecureServer", clientProtocol))
{
Console.WriteLine("Connected to server. Press ENTER to quit.");
Console.ReadLine();
}
}
}
```
Comments: ** Comment from web user: Rainbird **
``` c#
// Compile: csc test.cs /r:Zyan.Communication.dll
using System;
using System.Collections;
using System.Linq;
using Zyan.Communication;
using Zyan.Communication.Protocols.Tcp;
using Zyan.Communication.Security;
struct Program
{
static void Main(string[] args)
{
if (args.Any())
RunClient(args);
else
RunServer();
}
static void RunServer()
{
var port = 1234;
var auth = new NullAuthenticationProvider();
var protocol = new TcpDuplexServerProtocolSetup(port, auth, true);
using (var host = new ZyanComponentHost("SecureServer", protocol))
{
Console.WriteLine("Server started. Press ENTER to quit");
Console.ReadLine();
}
}
static void RunClient(string[] args)
{
// insecure client
var clientProtocol = new TcpDuplexClientProtocolSetup(false);
using (var conn1 = new ZyanConnection("tcpex://localhost:1234/SecureServer", clientProtocol))
{
Console.WriteLine("Connected to server. Press ENTER to quit.");
Console.ReadLine();
}
}
}
```
Comments: ** Comment from web user: Rainbird **
I found another solution, without the above mentioned dirty hack. Instead of throwing CryptoRemotingException, I send a message with an empty stream to the next sink. This results in a SerializationException, which is catched on client side.
See ChangeSet 31657.
Further improvements are welcome ;)