(self, data, only_handshake=False)
return (ssldata, appdata)
Feed SSL record level data into the pipe.

        The data must be a bytes instance. It is OK to send an empty bytes
        instance. This can be used to get ssldata for a handshake initiated by
        this endpoint.

        Return a (ssldata, appdata) tuple. The ssldata element is a list of
        buffers containing SSL data that needs to be sent to the remote SSL.

        The appdata element is a list of buffers containing plaintext data that
        needs to be forwarded to the application. The appdata list may contain
        an empty buffer indicating an SSL "close_notify" alert. This alert must
        be acknowledged by calling shutdown().
Feed SSL record level data into the pipe.
Feed SSL record level data into the pipe .
def feed_ssldata(self, data, only_handshake=False):
        """Feed SSL record level data into the pipe.

        The data must be a bytes instance. It is OK to send an empty bytes
        instance. This can be used to get ssldata for a handshake initiated by
        this endpoint.

        Return a (ssldata, appdata) tuple. The ssldata element is a list of
        buffers containing SSL data that needs to be sent to the remote SSL.

        The appdata element is a list of buffers containing plaintext data that
        needs to be forwarded to the application. The appdata list may contain
        an empty buffer indicating an SSL "close_notify" alert. This alert must
        be acknowledged by calling shutdown().
        """
        if self._state == _UNWRAPPED:
            # If unwrapped, pass plaintext data straight through.
            if data:
                appdata = [data]
            else:
                appdata = []
            return ([], appdata)

        self._need_ssldata = False
        if data:
            self._incoming.write(data)

        ssldata = []
        appdata = []
        try:
            if self._state == _DO_HANDSHAKE:
                # Call do_handshake() until it doesn't raise anymore.
                self._sslobj.do_handshake()
                self._state = _WRAPPED
                if self._handshake_cb:
                    self._handshake_cb(None)
                if only_handshake:
                    return (ssldata, appdata)
                # Handshake done: execute the wrapped block

            if self._state == _WRAPPED:
                # Main state: read data from SSL until close_notify
                while True:
                    chunk = self._sslobj.read(self.max_size)
                    appdata.append(chunk)
                    if not chunk:  # close_notify
                        break

            elif self._state == _SHUTDOWN:
                # Call shutdown() until it doesn't raise anymore.
                self._sslobj.unwrap()
                self._sslobj = None
                self._state = _UNWRAPPED
                if self._shutdown_cb:
                    self._shutdown_cb()

            elif self._state == _UNWRAPPED:
                # Drain possible plaintext data after close_notify.
                appdata.append(self._incoming.read())
        except (ssl.SSLError, ssl.CertificateError) as exc:
            exc_errno = getattr(exc, 'errno', None)
            if exc_errno not in (
                    ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE,
                    ssl.SSL_ERROR_SYSCALL):
                if self._state == _DO_HANDSHAKE and self._handshake_cb:
                    self._handshake_cb(exc)
                raise
            self._need_ssldata = (exc_errno == ssl.SSL_ERROR_WANT_READ)

        # Check for record level data that needs to be sent back.
        # Happens for the initial handshake and renegotiations.
        if self._outgoing.pending:
            ssldata.append(self._outgoing.read())
        return (ssldata, appdata)
def feed_ssldata ( self , data , only_handshake = False ) : if self . _state == _UNWRAPPED : # If unwrapped, pass plaintext data straight through. if data : appdata = [ data ] else : appdata = [ ] return ( [ ] , appdata ) self . _need_ssldata = False if data : self . _incoming . write ( data ) ssldata = [ ] appdata = [ ] try : if self . _state == _DO_HANDSHAKE : # Call do_handshake() until it doesn't raise anymore. self . _sslobj . do_handshake ( ) self . _state = _WRAPPED if self . _handshake_cb : self . _handshake_cb ( None ) if only_handshake : return ( ssldata , appdata ) # Handshake done: execute the wrapped block if self . _state == _WRAPPED : # Main state: read data from SSL until close_notify while True : chunk = self . _sslobj . read ( self . max_size ) appdata . append ( chunk ) if not chunk : # close_notify break elif self . _state == _SHUTDOWN : # Call shutdown() until it doesn't raise anymore. self . _sslobj . unwrap ( ) self . _sslobj = None self . _state = _UNWRAPPED if self . _shutdown_cb : self . _shutdown_cb ( ) elif self . _state == _UNWRAPPED : # Drain possible plaintext data after close_notify. appdata . append ( self . _incoming . read ( ) ) except ( ssl . SSLError , ssl . CertificateError ) as exc : exc_errno = getattr ( exc , 'errno' , None ) if exc_errno not in ( ssl . SSL_ERROR_WANT_READ , ssl . SSL_ERROR_WANT_WRITE , ssl . SSL_ERROR_SYSCALL ) : if self . _state == _DO_HANDSHAKE and self . _handshake_cb : self . _handshake_cb ( exc ) raise self . _need_ssldata = ( exc_errno == ssl . SSL_ERROR_WANT_READ ) # Check for record level data that needs to be sent back. # Happens for the initial handshake and renegotiations. if self . _outgoing . pending : ssldata . append ( self . _outgoing . read ( ) ) return ( ssldata , appdata )