From 9118da9acc0c94fcd0e2820c8e65a4e9a5213abc Mon Sep 17 00:00:00 2001 From: Chris Conlon Date: Wed, 14 Aug 2019 09:40:15 -0600 Subject: [PATCH] handle SSL_ERROR_WANT_WRITE in SSLSocket.sendall --- src/wolfssl/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/wolfssl/__init__.py b/src/wolfssl/__init__.py index 168b895..ee796b7 100644 --- a/src/wolfssl/__init__.py +++ b/src/wolfssl/__init__.py @@ -520,9 +520,17 @@ class SSLSocket(object): sent = 0 while sent < length: - sent += self.write(data[sent:]) + ret = self.write(data[sent:]) + if (ret < 0): + err = _lib.wolfSSL_get_error(self.native_object, 0) + if err == _SSL_ERROR_WANT_WRITE: + raise SSLWantWriteError() + else: + raise SSLError("wolfSSL_write error (%d)" % err) - return sent + sent += ret + + return None def sendto(self, data, flags_or_addr, addr=None): # Ensures not to send unencrypted data trying to use this method @@ -638,6 +646,7 @@ class SSLSocket(object): sock_type=self._sock.type, proto=self._sock.proto, fileno=self._sock.fileno()) + sock.settimeout(self._sock.gettimeout()) self._sock.detach()