commit 27292c9c868694ca19e2d2b9aa9c32220f9d89cf Author: Isis Lovecruft isis@torproject.org Date: Thu Feb 28 17:57:05 2013 +0000
Fix method doHandshake() to callback to handleWantRead() and handleWantWrite(). --- nettests/experimental/tls_handshake.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/nettests/experimental/tls_handshake.py b/nettests/experimental/tls_handshake.py index 3c9a033..e443242 100644 --- a/nettests/experimental/tls_handshake.py +++ b/nettests/experimental/tls_handshake.py @@ -553,17 +553,29 @@ class TLSHandshakeTest(nettest.NetTestCase): """ peername, peerport = connection.getpeername()
- log.msg("Attempting handshake: %s" % peername) - connection.do_handshake() - log.debug("State: %s" % connection.state_string()) - if connection.state_string() == \ - 'SSL negotiation finished successfully': + try: + log.msg("Attempting handshake: %s" % peername) + connection.do_handshake() + except OpenSSL.SSL.WantReadError() as wre: + self.state = connection.state_string() + log.debug("Handshake state: %s" % self.state) + log.debug("doHandshake: WantReadError on first handshake attempt.") + connection = handleWantRead(connection) + except OpenSSL.SSL.WantWriteError() as wwe: + self.state = connection.state_string() + log.debug("Handshake state: %s" % self.state) + log.debug("doHandshake: WantWriteError on first handshake attempt.") + connection = handleWantWrite(connection) + else: + self.state = connection.state_string() + + if self.state == 'SSL negotiation finished successfully': ## jump to handshakeSuccessful and get certchain return connection - else: sent = connection.send("o\r\n") - log.debug("State: %s" % connection.state_string()) + self.state = connection.state_string() + log.debug("Handshake state: %s" % self.state) log.debug("Transmitted %d bytes" % sent)
_read_buffer = connection.pending()