[tor-commits] [ooni-probe/develop] Add connectionRenegotiate() method for calling methods to either handle

isis at torproject.org isis at torproject.org
Thu Jun 6 16:41:37 UTC 2013


commit 4ad6a7e1ea528b72731c509bddc63562f1b79f86
Author: Isis Lovecruft <isis at torproject.org>
Date:   Thu Feb 28 04:17:13 2013 +0000

    Add connectionRenegotiate() method for calling methods to either handle
    SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE, as may be the case.
---
 nettests/experimental/tls_handshake.py |   25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/nettests/experimental/tls_handshake.py b/nettests/experimental/tls_handshake.py
index d84f174..81cab6a 100644
--- a/nettests/experimental/tls_handshake.py
+++ b/nettests/experimental/tls_handshake.py
@@ -271,7 +271,30 @@ class TLSHandshakeTest(nettest.NetTestCase):
 
             return connection
 
-        def doHandshake(connection):
+        def connectionRenegotiate(connection, host, error_message):
+            log.msg("Server requested renegotiation from: %s" % host)
+            log.debug("Renegotiation reason: %s" % error_message)
+            log.debug("State: %s" % connection.state_string())
+
+            if connection.renegotiate():
+                log.debug("Renegotiation possible.")
+                log.message("Retrying handshake with %s..." % host)
+                try:
+                    connection.do_handshake()
+                    while connection.renegotiate_pending():
+                        log.msg("Renegotiation with %s in progress..." % host)
+                        log.debug("State: %s" % connection.state_string())
+                        sleep(1)
+                    else:
+                        log.msg("Renegotiation with %s complete!" % host)
+                except SSL.WantReadError, wre:
+                    connection = handleWantRead(connection)
+                    log.debug("State: %s" % connection.state_string())
+                except SSL.WantWriteError, wwe:
+                    connection = handleWantWrite(connection)
+                    log.debug("State: %s" % connection.state_string())
+            return connection
+
             try:
                 connection.do_handshake()
             except SSL.WantReadError():





More information about the tor-commits mailing list