Skip to content

Commit

Permalink
# This is a combination of 3 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

Updated SSL.py to fix problem caused by SSL_WANT_READ or SSL_WANT_WRITE 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.
# This is the commit message pyca#2:

fixed format for flake8/black

# This is the commit message pyca#3:

E721 errors raised by flake8
  • Loading branch information
julianz- committed Jan 26, 2024
1 parent 7f3e4f9 commit 9212f66
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/OpenSSL/SSL.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,10 @@ 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
8 changes: 4 additions & 4 deletions tests/test_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ def test_construction(self):
certificate = X509()
assert isinstance(certificate, X509)
assert type(certificate).__name__ == "X509"
assert type(certificate) == X509
assert type(certificate) is X509

def test_set_version_wrong_args(self):
"""
Expand Down Expand Up @@ -3148,7 +3148,7 @@ def test_construction(self):
"""
revoked = Revoked()
assert isinstance(revoked, Revoked)
assert type(revoked) == Revoked
assert type(revoked) is Revoked
assert revoked.get_serial() == b"00"
assert revoked.get_rev_date() is None
assert revoked.get_reason() is None
Expand Down Expand Up @@ -3443,8 +3443,8 @@ def test_get_revoked(self):

revs = crl.get_revoked()
assert len(revs) == 2
assert type(revs[0]) == Revoked
assert type(revs[1]) == Revoked
assert type(revs[0]) is Revoked
assert type(revs[1]) is Revoked
assert revs[0].get_serial() == b"03AB"
assert revs[1].get_serial() == b"0100"
assert revs[0].get_rev_date() == now
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def join_bytes_or_unicode(prefix, suffix):
The return type is the same as the type of ``prefix``.
"""
# If the types are the same, nothing special is necessary.
if type(prefix) == type(suffix):
if type(prefix) is type(suffix):
return join(prefix, suffix)

# Otherwise, coerce suffix to the type of prefix.
Expand Down

0 comments on commit 9212f66

Please sign in to comment.