Skip to content

Commit

Permalink
Fix for problem caused by SSL_WANT_READ or SSL_WANT_WRITE errors.
Browse files Browse the repository at this point in the history
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 Jan 28, 2024
1 parent 482b95e commit 23e9e11
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ Changelog
Versions are year-based with a strict backward-compatibility policy.
The third digit is only for regressions.

24.1.0 (UNRELEASED)
-------------------

Backward-incompatible changes:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- ``pyOpenSSL`` now sets ``SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER`` by default, matching CPython's behavior. `#1287 <https://github.com/pyca/pyopenssl/pull/1287>`_.
- The minimum ``cryptography`` version is now 42.0.0.

Deprecations:
^^^^^^^^^^^^^

Changes:
^^^^^^^^



24.0.0 (2024-01-22)
-------------------

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def find_meta(meta):
packages=find_packages(where="src"),
package_dir={"": "src"},
install_requires=[
"cryptography>=41.0.5,<43",
"cryptography>=42.0.0,<43",
],
extras_require={
"test": ["flaky", "pretend", "pytest>=3.0.1"],
Expand Down
6 changes: 4 additions & 2 deletions src/OpenSSL/SSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,10 @@ def __init__(self, method):
self._ocsp_data = None
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
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extras =
test
deps =
coverage>=4.2
cryptographyMinimum: cryptography==41.0.5
cryptographyMinimum: cryptography==42.0.0
randomorder: pytest-randomly
setenv =
# Do not allow the executing environment to pollute the test environment
Expand Down

0 comments on commit 23e9e11

Please sign in to comment.