Login  
Search All Forums
Dart Home | PowerTCP Sockets for .NET | Custom Development Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
AuthorForum: PowerTCP Sockets for .NET (Secure and Standard)
Topic: PowerTCP SSL Sockets SecureProtocol Auto Negotiation Problem
cbenard

From: USA
Posts: 21
Member Since: 04/20/07
posted December 3, 2008 2:24 PM

Hello,

I have found what seems to be an error in the auto-negotiation used in Dart PowerTCP SSL Sockets. My browser (Chrome and Firefox) can connect and auto-negotiation to SSLv3 on a particular host, but Dart cannot. Dart can, however, auto-negotiate on other hosts. I’ve attached a sample program to demonstrate the problem with the host, 198.31.9.11.

Please advise a fix or workaround.

Below is reproduction code (.Net 3.5) and output:

Code
----------------------------------------------
using System;
using Dart.PowerTCP.SslSockets;

namespace DartAutoNegotiationTester
{
  class Program
  {
    class Host
    {
      public string Hostname { get; set; }
      public int Port { get; set; }
      public SecureProtocol SecureProtocol { get; set; }
    }

    static void Main(string[] args)
    {
      Host[] hosts = new Host[] {
        new Host() { Hostname = "www.newtechsys.com", Port = 443, SecureProtocol = SecureProtocol.Auto },
        new Host() { Hostname = "198.31.9.11", Port = 1158, SecureProtocol = SecureProtocol.Ssl3 },
        new Host() { Hostname = "198.31.9.11", Port = 1158, SecureProtocol = SecureProtocol.Auto },
      };

      foreach (var host in hosts)
      {
        using (Tcp sock = new Tcp())
        {
          sock.UseAuthentication = false;

          Console.WriteLine("Connecting to: {0}:{1}, Secure procotol: {2}...", host.Hostname, host.Port, host.SecureProtocol);
          try
          {
            sock.SecureProtocol = host.SecureProtocol;
            sock.Connect(host.Hostname, host.Port);
            Console.WriteLine("Done.");
          }
          catch (Exception ex)
          {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Exception: {0}", ex);
            Console.ResetColor();
          }
        }
        Console.WriteLine();
      }

      Console.WriteLine("Press Enter to exit.");
      Console.ReadLine();
    }
  }
}
----------------------------------------------

Output
----------------------------------------------
Connecting to: www.newtechsys.com:443, Secure procotol: Auto...
Done.

Connecting to: 198.31.9.11:1158, Secure procotol: Ssl3...
Done.

Connecting to: 198.31.9.11:1158, Secure procotol: Auto...
Exception: System.InvalidOperationException: The message received was unexpected
 or badly formatted
  at as.Invoke(Delegate A_0, Object[] A_1)
  at Dart.PowerTCP.SslSockets.Tcp.Connect(String server, Int32 serverPort, String client, Int32 clientPortMin, Int32 clientPortMax)
  at Dart.PowerTCP.SslSockets.Tcp.Connect(String server, Int32 serverPort)
  at DartAutoNegotiationTester.Program.Main(String[] args) in c:\Kittens\DartAutoNegotiationTester\DartAutoNegotiationTester\Program.cs:line 33

Press Enter to exit.
----------------------------------------------
cbenard

From: USA
Posts: 21
Member Since: 04/20/07
posted March 12, 2009 1:45 PM

This problem still exists in 1.1.1.0.
K M Drake



From: Utica, NY USA
Posts: 3406
Member Since: 07/14/00
posted March 17, 2009 10:48 AM

Hi,
I tried connecting to this address and port with version 1.1.1.0, but it seemed to work for both Ssl3 and Auto.
I did not get an error in either case.
I used VS.NET 2008.

Are you sure you tried with this version?
Thanks,
-ken

------
-Non-current subscribers must contact sales@dart.com to update subscription and receive continued support as needed.
------

cbenard

From: USA
Posts: 21
Member Since: 04/20/07
posted March 17, 2009 10:53 AM

Yes, I tried with 1.1.1.0.

Per Jason Farrar, you guys opened a trouble ticket with Microsoft about this on 12/3/2008, blaming them.

This error occurs only on Vista and Server 2008 (and I would assume Windows 7, but I haven't tried it there yet).

Please find a workaround for this.
Jason Farrar (Admin)

From: Oneida, NY USA
Posts: 223
Member Since: 07/24/07

Extra Support Options
Custom Application Development

posted March 17, 2009 11:44 AM

The work around is to try Auto and if that fails then try the other protocols, something like:

      foreach(SecureProtocol protocol in Enum.GetValues(typeof(SecureProtocol)))
      {
        try
        {
          sock.SecureProtocol = protocol;
          sock.Connect(host.Hostname, host.Port);
          //the break below will only get hit when the connection succeeds,
          //otherwise we keep looping through the protocols.
          break;
        }
        catch
        {}
      }

*EDIT: The above code snippet will loop through all of the protocols including Auto, it "should" start with Auto, at least it does in my testing.
Reply | PowerTCP Sockets for .NET (Secure and Standard) Topics | Forums   
This site is powered by PowerTCP WebServer Tool PowerTCP WebServer for ActiveX