[Twisted-Python] Where to catch ssl error exception?

Jp Calderone exarkun at divmod.com
Wed Feb 23 21:09:47 MST 2005


On Wed, 23 Feb 2005 17:00:31 -0500 (EST), Yun Mao <maoy at cis.upenn.edu> wrote:
>Suppose I'm the ssl server and a client didn't follow ssl protocol 
> somewhere, I can get an exception like following. The qustion is how can 
> I catch it?
> 

  Twisted 1.3 doesn't make this easily possible.  You could jump through 
some hoops to notice the SSL.Error with a custom log observer in conjunction
with a connectionLost callback.  In 2.0, connectionLost will simply be handed 
an error indicating the SSL problem and nothing will be logged by default.  
Short of replacing the default log observer entirely with one which does not 
log SSL errors, there is no way to prevent tracebacks like the one you included
from ending up in the log.  These tracebacks do not indicate any further problem 
than the one they describe.  That is to say, something has gone wrong on the SSL
layer, and the connection is going to be lost no matter what you do; it is 
unfortunate that the SSL error cannot be silenced, but in logging it, Twisted is 
indicating nothing more serious than that the connection is about to be lost.

  If you only need notification of the lost connection, not details regarding 
the specifics of the SSL failure, connectionLost in 1.3 should already provide 
you with enough information.

  Jp




More information about the Twisted-Python mailing list