[tor-commits] [ooni-probe/master] Change getContext() to only set the ciphersuite list, and add method

art at torproject.org art at torproject.org
Tue Apr 30 13:01:43 UTC 2013


commit dfc16658964a3bcbec5d94c970bde8c8927286d5
Author: Isis Lovecruft <isis at torproject.org>
Date:   Thu Feb 28 04:05:42 2013 +0000

    Change getContext() to only set the ciphersuite list, and add method
    getPeerCert() for dumping the server x509 certificate.
---
 nettests/experimental/tls_handshake.py |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/nettests/experimental/tls_handshake.py b/nettests/experimental/tls_handshake.py
index 2c11122..3e22f38 100644
--- a/nettests/experimental/tls_handshake.py
+++ b/nettests/experimental/tls_handshake.py
@@ -172,15 +172,15 @@ class TLSHandshakeTest(nettest.NetTestCase):
         return s
 
     def getContext(self):
-        if 'ssl2' in self.methods:
-            if not 'ssl3' in self.methods:
-                context = SSL.Context(SSL.SSLv2_METHOD)
-            else:
-                context = SSL.Context(SSL.SSLv23_METHOD)
-        elif 'ssl3' in self.methods:
-            context = SSL.Context(SSL.SSLv3_METHOD)
-        elif 'tls1' in self.methods:
-            context = SSL.Context(SSL.TLSv1_METHOD)
+        self.context.set_cipher_list(self.ciphersuite)
+        return self.context
+
+    @staticmethod
+    def getPeerCert(connection, get_chain=False):
+        if not get_chain:
+            x509_cert = connection.get_peer_certificate()
+            pem_cert = dump_certificate(FILETYPE_PEM, x509_cert)
+            return pem_cert
         else:
             raise Exception("No SSL/TLS method chosen!")
         context.set_cipher_list(self.ciphersuite)





More information about the tor-commits mailing list