Skip to content

Commit

Permalink
Updated SSL.py to fix problem caused by SSL_WANT_READ or SSL_WANT_WRI…
Browse files Browse the repository at this point in the history
…TE errors.

When SSL_WANT_READ or SSL_WANT_WRITE are encountered, it's typical to retry the call but this must be repeated with the exact same arguments. Without this change, openSSL requires that the address of the buffer passed is the same. However, buffers in python can change location in some circumstances which cause the retry to fail.  By add the setting SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER, the requirement for the same buffer address is forgiven and the retry has a better chance of success.  See cherrypy/cheroot#245 for discussion.
  • Loading branch information
julianz- committed Aug 18, 2023
1 parent b259bfb commit dda7525
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/OpenSSL/SSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ def __init__(self, method):
self._cookie_generate_helper = None
self._cookie_verify_helper = None

self.set_mode(_lib.SSL_MODE_ENABLE_PARTIAL_WRITE)
self.set_mode(_lib.SSL_MODE_ENABLE_PARTIAL_WRITE | _lib.SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER)
if version is not None:
self.set_min_proto_version(version)
self.set_max_proto_version(version)
Expand Down

0 comments on commit dda7525

Please sign in to comment.