Python ssl.SSL_ERROR_SYSCALL Examples
The following are 8
code examples of ssl.SSL_ERROR_SYSCALL().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
ssl
, or try the search function
.
Example #1
Source File: sslproto.py From Fluid-Designer with GNU General Public License v3.0 | 4 votes |
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. """ assert 0 <= offset <= len(data) if self._state == _UNWRAPPED: # pass through data in unwrapped mode if offset < len(data): ssldata = [data[offset:]] else: ssldata = [] return (ssldata, len(data)) ssldata = [] view = memoryview(data) while True: self._need_ssldata = False try: if offset < len(view): offset += self._sslobj.write(view[offset:]) except ssl.SSLError as exc: # It is not allowed to call write() after unwrap() until the # close_notify is acknowledged. We return the condition to the # caller as a short write. if exc.reason == 'PROTOCOL_IS_SHUTDOWN': exc.errno = ssl.SSL_ERROR_WANT_READ if exc.errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): raise self._need_ssldata = (exc.errno == ssl.SSL_ERROR_WANT_READ) # See if there's any record level data back for us. if self._outgoing.pending: ssldata.append(self._outgoing.read()) if offset == len(view) or self._need_ssldata: break return (ssldata, offset)
Example #2
Source File: sslproto.py From Imogen with MIT License | 4 votes |
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. """ assert 0 <= offset <= len(data) if self._state == _UNWRAPPED: # pass through data in unwrapped mode if offset < len(data): ssldata = [data[offset:]] else: ssldata = [] return (ssldata, len(data)) ssldata = [] view = memoryview(data) while True: self._need_ssldata = False try: if offset < len(view): offset += self._sslobj.write(view[offset:]) except ssl.SSLError as exc: # It is not allowed to call write() after unwrap() until the # close_notify is acknowledged. We return the condition to the # caller as a short write. exc_errno = getattr(exc, 'errno', None) if exc.reason == 'PROTOCOL_IS_SHUTDOWN': exc_errno = exc.errno = ssl.SSL_ERROR_WANT_READ if exc_errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): raise self._need_ssldata = (exc_errno == ssl.SSL_ERROR_WANT_READ) # See if there's any record level data back for us. if self._outgoing.pending: ssldata.append(self._outgoing.read()) if offset == len(view) or self._need_ssldata: break return (ssldata, offset)
Example #3
Source File: sslproto.py From ironpython3 with Apache License 2.0 | 4 votes |
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. """ assert 0 <= offset <= len(data) if self._state == _UNWRAPPED: # pass through data in unwrapped mode if offset < len(data): ssldata = [data[offset:]] else: ssldata = [] return (ssldata, len(data)) ssldata = [] view = memoryview(data) while True: self._need_ssldata = False try: if offset < len(view): offset += self._sslobj.write(view[offset:]) except ssl.SSLError as exc: # It is not allowed to call write() after unwrap() until the # close_notify is acknowledged. We return the condition to the # caller as a short write. if exc.reason == 'PROTOCOL_IS_SHUTDOWN': exc.errno = ssl.SSL_ERROR_WANT_READ if exc.errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): raise self._need_ssldata = (exc.errno == ssl.SSL_ERROR_WANT_READ) # See if there's any record level data back for us. if self._outgoing.pending: ssldata.append(self._outgoing.read()) if offset == len(view) or self._need_ssldata: break return (ssldata, offset)
Example #4
Source File: sslproto.py From annotated-py-projects with MIT License | 4 votes |
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. """ assert 0 <= offset <= len(data) if self._state == _UNWRAPPED: # pass through data in unwrapped mode if offset < len(data): ssldata = [data[offset:]] else: ssldata = [] return (ssldata, len(data)) ssldata = [] view = memoryview(data) while True: self._need_ssldata = False try: if offset < len(view): offset += self._sslobj.write(view[offset:]) except ssl.SSLError as exc: # It is not allowed to call write() after unwrap() until the # close_notify is acknowledged. We return the condition to the # caller as a short write. if exc.reason == 'PROTOCOL_IS_SHUTDOWN': exc.errno = ssl.SSL_ERROR_WANT_READ if exc.errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): raise self._need_ssldata = (exc.errno == ssl.SSL_ERROR_WANT_READ) # See if there's any record level data back for us. if self._outgoing.pending: ssldata.append(self._outgoing.read()) if offset == len(view) or self._need_ssldata: break return (ssldata, offset)
Example #5
Source File: sslproto.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 4 votes |
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. """ assert 0 <= offset <= len(data) if self._state == _UNWRAPPED: # pass through data in unwrapped mode if offset < len(data): ssldata = [data[offset:]] else: ssldata = [] return (ssldata, len(data)) ssldata = [] view = memoryview(data) while True: self._need_ssldata = False try: if offset < len(view): offset += self._sslobj.write(view[offset:]) except ssl.SSLError as exc: # It is not allowed to call write() after unwrap() until the # close_notify is acknowledged. We return the condition to the # caller as a short write. if exc.reason == 'PROTOCOL_IS_SHUTDOWN': exc.errno = ssl.SSL_ERROR_WANT_READ if exc.errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): raise self._need_ssldata = (exc.errno == ssl.SSL_ERROR_WANT_READ) # See if there's any record level data back for us. if self._outgoing.pending: ssldata.append(self._outgoing.read()) if offset == len(view) or self._need_ssldata: break return (ssldata, offset)
Example #6
Source File: sslproto.py From odoo13-x64 with GNU General Public License v3.0 | 4 votes |
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. """ assert 0 <= offset <= len(data) if self._state == _UNWRAPPED: # pass through data in unwrapped mode if offset < len(data): ssldata = [data[offset:]] else: ssldata = [] return (ssldata, len(data)) ssldata = [] view = memoryview(data) while True: self._need_ssldata = False try: if offset < len(view): offset += self._sslobj.write(view[offset:]) except ssl.SSLError as exc: # It is not allowed to call write() after unwrap() until the # close_notify is acknowledged. We return the condition to the # caller as a short write. exc_errno = getattr(exc, 'errno', None) if exc.reason == 'PROTOCOL_IS_SHUTDOWN': exc_errno = exc.errno = ssl.SSL_ERROR_WANT_READ if exc_errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): raise self._need_ssldata = (exc_errno == ssl.SSL_ERROR_WANT_READ) # See if there's any record level data back for us. if self._outgoing.pending: ssldata.append(self._outgoing.read()) if offset == len(view) or self._need_ssldata: break return (ssldata, offset)
Example #7
Source File: sslproto.py From Carnets with BSD 3-Clause "New" or "Revised" License | 4 votes |
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. """ assert 0 <= offset <= len(data) if self._state == _UNWRAPPED: # pass through data in unwrapped mode if offset < len(data): ssldata = [data[offset:]] else: ssldata = [] return (ssldata, len(data)) ssldata = [] view = memoryview(data) while True: self._need_ssldata = False try: if offset < len(view): offset += self._sslobj.write(view[offset:]) except ssl.SSLError as exc: # It is not allowed to call write() after unwrap() until the # close_notify is acknowledged. We return the condition to the # caller as a short write. exc_errno = getattr(exc, 'errno', None) if exc.reason == 'PROTOCOL_IS_SHUTDOWN': exc_errno = exc.errno = ssl.SSL_ERROR_WANT_READ if exc_errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): raise self._need_ssldata = (exc_errno == ssl.SSL_ERROR_WANT_READ) # See if there's any record level data back for us. if self._outgoing.pending: ssldata.append(self._outgoing.read()) if offset == len(view) or self._need_ssldata: break return (ssldata, offset)
Example #8
Source File: sslproto.py From android_universal with MIT License | 4 votes |
def feed_appdata(self, data, offset=0): """Feed plaintext data into the pipe. Return an (ssldata, offset) tuple. The ssldata element is a list of buffers containing record level data that needs to be sent to the remote SSL instance. The offset is the number of plaintext bytes that were processed, which may be less than the length of data. NOTE: In case of short writes, this call MUST be retried with the SAME buffer passed into the *data* argument (i.e. the id() must be the same). This is an OpenSSL requirement. A further particularity is that a short write will always have offset == 0, because the _ssl module does not enable partial writes. And even though the offset is zero, there will still be encrypted data in ssldata. """ assert 0 <= offset <= len(data) if self._state == _UNWRAPPED: # pass through data in unwrapped mode if offset < len(data): ssldata = [data[offset:]] else: ssldata = [] return (ssldata, len(data)) ssldata = [] view = memoryview(data) while True: self._need_ssldata = False try: if offset < len(view): offset += self._sslobj.write(view[offset:]) except ssl.SSLError as exc: # It is not allowed to call write() after unwrap() until the # close_notify is acknowledged. We return the condition to the # caller as a short write. exc_errno = getattr(exc, 'errno', None) if exc.reason == 'PROTOCOL_IS_SHUTDOWN': exc_errno = exc.errno = ssl.SSL_ERROR_WANT_READ if exc_errno not in (ssl.SSL_ERROR_WANT_READ, ssl.SSL_ERROR_WANT_WRITE, ssl.SSL_ERROR_SYSCALL): raise self._need_ssldata = (exc_errno == ssl.SSL_ERROR_WANT_READ) # See if there's any record level data back for us. if self._outgoing.pending: ssldata.append(self._outgoing.read()) if offset == len(view) or self._need_ssldata: break return (ssldata, offset)