diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 6e23770d..6305898c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -225,6 +225,10 @@ Deprecations: Changes: ^^^^^^^^ +- Fixed the inability of ``OpenSSL.SSL.Connection.sendall()`` to + keep with sending data over the wire after ``SSL_ERROR_WANT_READ`` + or ``SSL_ERROR_WANT_WRITE`` is returned by ``SSL_write()``. + `#176 `_ - Added a new optional ``chain`` parameter to ``OpenSSL.crypto.X509StoreContext()`` where additional untrusted certificates can be specified to help chain building. `#948 `_ diff --git a/src/OpenSSL/SSL.py b/src/OpenSSL/SSL.py index 4db5240e..2ac897f7 100644 --- a/src/OpenSSL/SSL.py +++ b/src/OpenSSL/SSL.py @@ -2053,7 +2053,14 @@ def sendall(self, buf, flags=0): result = _lib.SSL_write( self._ssl, data + total_sent, min(left_to_send, 2147483647) ) - self._raise_ssl_error(self._ssl, result) + try: + self._raise_ssl_error(self._ssl, result) + except (WantReadError, WantWriteError): + # NOTE: The use of SSL_MODE_ENABLE_PARTIAL_WRITE + # NOTE: above guarantees that in case of failure + # NOTE: no bytes have been written so we don't need + # NOTE: to update the counters, just need to retry. + continue total_sent += result left_to_send -= result