MySSLIOHandler bug

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
icecoke
Posts: 6
Joined: Sat 21 Jun 2008 23:24

MySSLIOHandler bug

Post by icecoke » Sun 22 Jun 2008 18:19

Hi there,

I'm not sure if it is a bug, but it seems that way. When I try to include any visual function (changeing a textbox, showing a message) within OnServerCertValidate it will hang endless.

I wanted to ask the user for accepting the certificate from the server, but all tries failed. Just include such a line into the event to reproduce:

ShowMessage(ServerCertificate.Subject)

Any help is welcome.

best regards,
icecoke

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 23 Jun 2008 12:40

Point is that the OnServerCertValidate event is raised in a separate thread. To use VCL components you should synchronize with the main thread, e.g. with using a timer.

icecoke
Posts: 6
Joined: Sat 21 Jun 2008 23:24

Post by icecoke » Mon 23 Jun 2008 22:50

Dimon,

I would love to do that, but it seems this event is blocking the main thread. I tried with messages (don't like timers) and the main thread is just dead and not able to do any work nor able to get the message.
The message is processed right after this blocking event is finished.

So, how should the main thread show any messagebox or something like this, even if I place a timer?

Any advice is welcome.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 24 Jun 2008 13:13

Really the main thread is blocked until the OnServerCertValidate event is not finished and you can't use VCL components in this event handler.
In order to solve this problem, you can use trusted certificate list and find ServerCertificate in this list. If the certificate is not found then set Accept to False. In main thread you can ask the user to accept the certificate, and if the certificate is accepted, then perform reconnect.
You can use for this the following code:

Code: Select all

  try
    MyConnection.Connect;
  except
    on e: EScError do begin
      if e.Message = SCertificateNotVerified then begin
        // Check certificate
        ...
        MyConnection.Connect;
      end;
  end;

icecoke
Posts: 6
Joined: Sat 21 Jun 2008 23:24

Post by icecoke » Tue 24 Jun 2008 17:10

This is quite a workaround - no straight programming. Do you have plans to change this way of behavior? I would love to handle such events and reactions within the class events.

icecoke
Posts: 6
Joined: Sat 21 Jun 2008 23:24

Post by icecoke » Tue 24 Jun 2008 17:32

Dimon wrote:

Code: Select all

    on e: EScError do begin
      if e.Message = SCertificateNotVerified then begin
        // Check certificate
        ...
Hmm - that seems to be impossible, cause the connection is down, so no certificate to check anymore... Do you really expect I have to save this in a different component to recheck it in this exception? I'm sorry, but did noone else had this problems? I'm a little confused - securebridge seems not to be that transparent as I expected it...
Anyway, I will try it - but I would love to have this more inline.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 25 Jun 2008 06:56

We will investigate the possibility of changing this behaviour in the near future.

Post Reply