[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/develop] Switch to setting the TLS/SSL methods in setUp(), rather than in getContext().



commit a00f0700f0d6f2e3eed700f8c9bb8a5c77097d8b
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Thu Feb 28 03:38:21 2013 +0000

    Switch to setting the TLS/SSL methods in setUp(), rather than in getContext().
---
 nettests/experimental/tls_handshake.py |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/nettests/experimental/tls_handshake.py b/nettests/experimental/tls_handshake.py
index 6474792..c57545c 100644
--- a/nettests/experimental/tls_handshake.py
+++ b/nettests/experimental/tls_handshake.py
@@ -101,7 +101,6 @@ class TLSHandshakeTest(nettest.NetTestCase):
         if self.localOptions:
             options = self.localOptions
             self.ciphers = []
-            self.methods = []
 
             ## check that we're testing an IP:PORT, else exit gracefully:
             if not ((options['host'] and options['port']) or options['file']):
@@ -111,9 +110,22 @@ class TLSHandshakeTest(nettest.NetTestCase):
             ##     one of the TLS/SSL methods at a time.
 
             ## set the SSL/TLS method to use:
-            for method in ['ssl2', 'ssl3', 'tls1']:
-                if options[method]:
-                    self.methods.append(method)
+            if options['ssl2']:
+                if not options['ssl3']:
+                    self.context = SSL.Context(SSL.SSLv2_METHOD)
+                else:
+                    self.context = SSL.Context(SSL.SSLv23_METHOD)
+            elif options['ssl3']:
+                self.context = SSL.Context(SSL.SSLv3_METHOD)
+            elif options['tls1']:
+                self.context = SSL.Context(SSL.TLSv1_METHOD)
+            else:
+                try:
+                    raise NoSSLContextError(
+                        "No SSL/TLS context chosen! Defaulting to TLSv1...")
+                except NoSSLContextError, ncse:
+                    log.err(ncse.message)
+                    self.context = SSL.Context(SSL.TLSv1_METHOD)
 
             if not options['ciphersuite']:
                 self.ciphers = firefox_ciphers



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits