From abe335e57dd2871a6ea6cfe2559f9b29ae0c33bb Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Tue, 26 Jun 2012 23:52:35 +1200 Subject: [PATCH] Add a flag to track SSL connection establishment. --- netlib/tcp.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/netlib/tcp.py b/netlib/tcp.py index aa923fddc..9b1fc65e4 100644 --- a/netlib/tcp.py +++ b/netlib/tcp.py @@ -52,6 +52,7 @@ class TCPClient: self.host, self.port = host, port self.connection, self.rfile, self.wfile = None, None, None self.cert = None + self.ssl_established = False def convert_to_ssl(self, clientcert=None, sni=None): context = SSL.Context(SSL.SSLv23_METHOD) @@ -68,6 +69,7 @@ class TCPClient: self.cert = self.connection.get_peer_certificate() self.rfile = FileLike(self.connection) self.wfile = FileLike(self.connection) + self.ssl_established = True def connect(self): try: @@ -94,6 +96,7 @@ class BaseHandler: self.client_address = client_address self.server = server self.finished = False + self.ssl_established = False def convert_to_ssl(self, cert, key): ctx = SSL.Context(SSL.SSLv23_METHOD) @@ -109,6 +112,7 @@ class BaseHandler: raise NetLibError("SSL handshake error: %s"%str(v)) self.rfile = FileLike(self.connection) self.wfile = FileLike(self.connection) + self.ssl_established = True def finish(self): self.finished = True