def do_handshake(self): log.debug("SSL handshaking", extra={"sock": self._sock}) def handshake_step(result): log.debug("SSL handshaking completed %s", result, extra={"sock": self._sock}) if not hasattr(self._sock, "active_latch"): log.debug("Post connect step", extra={"sock": self._sock}) self._sock._post_connect() self._sock._unlatch() self._sslobj = object() # we have now handshaked self._notify_selectors() if self.ssl_handler is None: self.ssl_handler = SslHandler(self.engine) self.ssl_handler.handshakeFuture().addListener(handshake_step) if hasattr(self._sock, "connected") and self._sock.connected: # The underlying socket is already connected, so some extra work to manage log.debug("Adding SSL handler to pipeline after connection", extra={"sock": self._sock}) self._sock.channel.pipeline().addFirst("ssl", self.ssl_handler) else: log.debug("Not connected, adding SSL initializer...", extra={"sock": self._sock}) self._sock.connect_handlers.append(SSLInitializer(self.ssl_handler)) handshake = self.ssl_handler.handshakeFuture() self._sock._handle_channel_future(handshake, "SSL handshake")
def do_handshake(self): log.debug("SSL handshaking", extra={"sock": self._sock}) self.setup_engine(self.sock.getpeername()) def handshake_step(result): log.debug("SSL handshaking completed %s", result, extra={"sock": self._sock}) self._notify_selectors() if self.ssl_handler is None: self.ssl_handler = SslHandler(self.engine) self.ssl_handler.handshakeFuture().addListener(handshake_step) if hasattr(self._sock, "connected") and self._sock.connected: # The underlying socket is already connected, so some extra work to manage log.debug("Adding SSL handler to pipeline after connection", extra={"sock": self._sock}) self._sock.channel.pipeline().addFirst("ssl", self.ssl_handler) else: log.debug("Not connected, adding SSL initializer...", extra={"sock": self._sock}) self._sock.connect_handlers.append(SSLInitializer(self.ssl_handler)) self._handshake_future = self.ssl_handler.handshakeFuture() if isinstance(self._sock, ChildSocket): pass # see # http://stackoverflow.com/questions/24628271/exception-in-netty-io-netty-util-concurrent-blockingoperationexception # - handshake in the child thread pool else: self._sock._handle_channel_future(self._handshake_future, "SSL handshake")
def do_handshake(self): log.debug("SSL handshaking", extra={"sock": self._sock}) self.setup_engine(self.sock.getpeername()) def handshake_step(result): log.debug("SSL handshaking completed %s", result, extra={"sock": self._sock}) if not hasattr(self._sock, "active_latch"): log.debug("Post connect step", extra={"sock": self._sock}) self._sock._post_connect() self._sock._unlatch() self._sslobj = object() # we have now handshaked self._notify_selectors() if self.ssl_handler is None: self.ssl_handler = SslHandler(self.engine) self.ssl_handler.handshakeFuture().addListener(handshake_step) if hasattr(self._sock, "connected") and self._sock.connected: # The underlying socket is already connected, so some extra work to manage log.debug("Adding SSL handler to pipeline after connection", extra={"sock": self._sock}) self._sock.channel.pipeline().addFirst("ssl", self.ssl_handler) else: log.debug("Not connected, adding SSL initializer...", extra={"sock": self._sock}) self._sock.connect_handlers.append(SSLInitializer(self.ssl_handler)) handshake = self.ssl_handler.handshakeFuture() time.sleep(0.001) # Necessary apparently for the handler to get into a good state if isinstance(self._sock, ChildSocket): # see # http://stackoverflow.com/questions/24628271/exception-in-netty-io-netty-util-concurrent-blockingoperationexception # - we are doing this in the handler thread! return try: self._sock._handle_channel_future(handshake, "SSL handshake") except socket_error, e: raise SSLError(SSL_ERROR_SSL, e.strerror)