def _gen_ssl_connect_fn(self, connection, post_fn):
        """Generate a bridge_fn for doing an ssl handshake on connection.
        Once the handshake is completed post_fn will be called
        """
        def do_ssl_handshake():
            try:
                connection.do_handshake()
                return post_fn()
            except (SSL.WantReadError, SSL.WantWriteError):
                pass
            except SSL.Error as e:
                self.handler.on_ssl_error(e)
                return False
            except socket.error as e:
                return False
            return True
        return do_ssl_handshake
Generate a bridge_fn for doing an ssl handshake on connection.
        Once the handshake is completed post_fn will be called
        
nogotofail/mitm/connection/connection.py