Home Forums Support Encryption require to set NetworkComms.DefaultSendReceiveOptions

Tagged: 

Viewing 10 posts - 1 through 10 (of 11 total)
  • Author
    Posts
  • #2589
    Anonymous
    Inactive

    Hello,

    My application has a few connections some encrypted and some not.
    First I tried like that:

    Creating options:

    var processors = new List<DataProcessor> { DPSManager.GetDataProcessor<SharpZipLibCompressor.SharpZipLibGzipCompressor>(), DPSManager.GetDataProcessor<RijndaelPSKEncrypter>() };
                    var dataOptions = new Dictionary<string, string>();                
                    RijndaelPSKEncrypter.AddPasswordToOptions(dataOptions, "godlike");
                    var options = new SendReceiveOptions(DPSManager.GetDataSerializer<ProtobufSerializer>(), processors, dataOptions) { UseNestedPacket = true };

    using them:

    var listener = new TCPConnectionListener(_options, ApplicationLayerProtocolStatus.Enabled);

    Doesn’t work. Got “Options must contain encryption key”. Which means that my key is not in the dictionary, but wait! I put it there.
    Then I tried that:

    RijndaelPSKEncrypter.AddPasswordToOptions(NetworkComms.DefaultSendReceiveOptions.Options, "godlike");

    Suddenly works!

    This is not the bug. It is design flaw. Encryption takes key/pass only from NetworkComms.DefaultSendReceiveOptions, but what if I need two different encrypted connections with different passwords? I MUST be missing something. I can’t believe that it is like that by design. Anyway it is not obvious at all, how one should handle situations like that.
    I hope I am wrong and there is a genuine and graceful way two handle to separate encrypted connections.
    Please, let me know.

    Regards,
    Igor.

    • This topic was modified 10 years, 6 months ago by .
    #2591
    Anonymous
    Inactive

    Heya Igor,

    Thanks for the post. How do you start listening for incoming connections?

    Regards,
    Marc

    #2593
    Anonymous
    Inactive

    Hi Marc,

    I do it like that:

     var listener = new TCPConnectionListener(_options, ApplicationLayerProtocolStatus.Enabled);
                    listener.AppendIncomingPacketHandler<string>("some message",
                                    (header, connection, customObject) =>
                                    {
                                        Console.WriteLine("\nReceived custom protobuf object from " + connection);
                                    });
    ....
    Connection.StartListening(listener, new IPEndPoint(ip, 0));

    Thanks for quick response.

    • This reply was modified 10 years, 6 months ago by .
    #2596
    Anonymous
    Inactive

    Heya iYalovoy,

    I am investigating the problem.

    Regards,
    Marc

    #2597
    Anonymous
    Inactive

    iYalovoy could you possible put together a simple console use case that demonstrates the problem and send me a download link, either forum or to support@networkcomms.net? This would allow me to find a solution faster.

    Regards,
    Marc

    #2598
    Anonymous
    Inactive

    Always happy to contribute to library development!
    [linkremoved]

    #2602
    Anonymous
    Inactive

    This is a genuine bug. For the time being you might be able to get around it by replacing the following line:

    listener.AppendIncomingPacketHandler<string>("Kill all humans",
                    (header, con, customObject) =>
                    {
                        Console.WriteLine("\nReceived custom protobuf object from " + con);
                    });

    with:

    listener.AppendIncomingPacketHandler<string>("Kill all humans",
                    (header, con, customObject) =>
                    {
                        Console.WriteLine("\nReceived custom protobuf object from " + con);
                    }, options);

    I’m working on a fix so that your use case works as expected. It should be released as part of 3.0.1.

    Regards,
    Marc

    #2603
    Anonymous
    Inactive

    Completly missed the fact, that AppendIncomingPacketHandler has SendReceiveOptions parameter.
    Anyway, thanks for quick response. Keep going good work!

    #2604
    Anonymous
    Inactive

    Well…
    “might be able to” Means you haven’t even checked?
    Because

    listener.AppendIncomingPacketHandler<string>("Kill all humans",
                    (header, con, customObject) =>
                    {
                        Console.WriteLine("\nReceived custom protobuf object from " + con);
                    }, options);

    doesn’t work as well.

    #2605
    Anonymous
    Inactive

    hmmm, it did work for me, perhaps I was on a different revision. I should hopefully be able to release 3.0.1 in a day or two which fixes it correctly.

    Marc

Viewing 10 posts - 1 through 10 (of 11 total)
  • You must be logged in to reply to this topic.