On Aug 20, 2012, at 4:52 AM, Phil Mayers <p.may...@imperial.ac.uk> wrote:
> All, > > It's been my observation that this code: > > class MyProto(protocol.Protocol): > > def connectionMade(self): > print self.transport.getPeerCertificate() > self.transport.loseConnection() > > class MyFactory(protocol.ClientFactory): > > def buildProtocol(self, addr): > return MyProto() > > def main(): > factory = MyFactory() > ctxfact = ssl.ClientContextFactory() > reactor.connectSSL(host, port, factory, ctxfact) > reactor.run() > > ...will print "None". It seems that connectSSL calls connectionMade at > TCP connection time, not when SSL has completed. This seems unintuitive > to me because I've called "connectSSL" not "connectTCP", but I guess may > be hard to fix given the way the code works? > > At the very least, should this be documented? > > Or could we have an interface e.g. > > class ISSLProtocol(interface): > def sslReady(): > """called when the SSL layer is ready""" > > ...and people who are interested can "implements()" it to get the callback? Yup, it's a bug, reported 3 years ago: <http://twistedmatrix.com/trac/ticket/3687> It's definitely a problem. Perhaps worse is the fact that startTLS() doesn't directly give you that notification either. Please feel free to contribute a fix :). -glyph _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python