-
Notifications
You must be signed in to change notification settings - Fork 420
Set SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER in calling OpenSSL #1287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
See #1242 for more context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pushing this further! 🍰 I think we had general agreement to do this in #1242, so this looks good to merge after some minor docs fixes. :)
We can ignore codecov, that seems to be a bug in determining coverage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add some empty line separators under title marks.
c2cae69
to
2e788b7
Compare
6c1d483
to
23e9e11
Compare
@mhils @alex it appears that https://app.codecov.io/gh/pyca/pyopenssl treats |
I've changed the default branch to be main |
Is there a smoke test we could include in this PR? |
@webknjaz The only test for setting the mode currently is:
This checks that setting the mode for MODE_RELEASE_BUFFERS returns the same bit. I guess we could add another check to make sure passing SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER also returns the appropriate value? Not sure whether that counts as a smoke test but it's something perhaps? |
Maybe, find some existing test where a write buffer is passed, copy it and pass a moving buffer there? @mhils ideas? |
We could possibly adapt something like this: https://github.com/pyca/pyopenssl/blob/main/tests/test_ssl.py#L2837 If that's easy to add I'm all for it, but I also feel that not having an elaborate test here is not the end of the world. There's precedent (SSL_MODE_ENABLE_PARTIAL_WRITE has no test either) and, more importantly, if this fails in the future we should get a very explicit 'bad write retry' error. Does CPython have a dedicated test for this? This looks good to merge otherwise. @alex @reaperhulk, if you want to make a judgement call here please just merge. :) |
@mhils Strangely, when I try running pytest locally on my branch I am getting an exception on that test that makes it fail the test:
That's just a fragment of the output so maybe not very meaningful but as I understand it, the test is meant to throw WantWriteError but for some reason although it's expected the exception is not being considered a success? How is this supposed to work? |
In your log, a more generic exception happens ( |
Ok to make any progress on this, I'm trying to understand the first test that is failing when I run pytest locally - test_set_default_verify_paths() in test_ssl.py. It's basically saying "certificate verify failed". I tried debugging this using the following in the command line:
and get:
I assume this generates an error because the return code is not 0. But how is this supposed to work? The test relies on Google's certificate but there seems to be problem with the cert? |
I have updated this PR, restoring the tests that were previously failing (your second point). I have also added two tests that check for the use of SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER, one for its presence and one for its absence (your third point). I still have had to remove py37-cryptographyMain from the CI matrix as it I got conflicts with the requirements in setup.py for cryptography that were already there: If you still want the removal of py37-cryptographyMain in separate PR let me know. |
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 reverts commit dee294a.
This reverts commit 339b193.
…t fails" This reverts commit 50654a8.
I am to get to it this weekend. |
See cherrypy/cheroot#245 for discussion.