Page 1 of 1
MySSLIOHandler bug
Posted: Sun 22 Jun 2008 18:19
by icecoke
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
Posted: Mon 23 Jun 2008 12:40
by Dimon
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.
Posted: Mon 23 Jun 2008 22:50
by icecoke
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.
Posted: Tue 24 Jun 2008 13:13
by Dimon
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;
Posted: Tue 24 Jun 2008 17:10
by icecoke
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.
Posted: Tue 24 Jun 2008 17:32
by icecoke
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.
Posted: Wed 25 Jun 2008 06:56
by Dimon
We will investigate the possibility of changing this behaviour in the near future.