Skip to content
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

bpo-24334: Cleanup SSLSocket #5252

Merged
merged 1 commit into from
Feb 24, 2018
Merged

Conversation

tiran
Copy link
Member

@tiran tiran commented Jan 20, 2018

  • The SSLSocket is no longer implemented on top of SSLObject to
    avoid an extra level of indirection.
  • Owner and session are now handled in the internal constructor.
  • _ssl._SSLSocket now uses the same method names as SSLSocket and
    SSLObject.
  • Channel binding type check is now handled in C code. Channel binding
    is always available.

The patch also changes the signature of SSLObject.init(). In my
opinion it's fine. A SSLObject is not a user-constructable object.
SSLContext.wrap_bio() is the only valid factory.

https://bugs.python.org/issue24334

Modules/_ssl.c Outdated
@@ -2309,19 +2323,21 @@ _ssl._SSLSocket.shutdown

Does the SSL shutdown handshake with the remote end.

Returns the underlying socket object.
Mode 0 is quiet shutdown, which does not send any CLOSE NOTIFY. Mode 2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do "mode 0" and "mode 2" refer to?

Lib/ssl.py Outdated
return self._sslobj.pending()
else:
return 0

def shutdown(self, how):
self._checkClosed()
self._sslobj = None
if self._sslobj is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the redundancy adds something here?

@tiran tiran force-pushed the bpo-24334-simplify-sslsocket branch from 76b519c to 7f303a7 Compare January 22, 2018 09:17
@tiran
Copy link
Member Author

tiran commented Jan 22, 2018

@pitrou I have addressed your review comments. Both places are remnants of another patch to implement more shutdown methods. I have removed them from this PR.

https://bugs.python.org/issue27815#msg310403 explains the additional shutdown methods. I decided to move new shutdown methods to another PR and get this PR out before beta1.

@tiran tiran force-pushed the bpo-24334-simplify-sslsocket branch from 7f303a7 to 2a4f5d2 Compare January 22, 2018 17:21
@tiran tiran force-pushed the bpo-24334-simplify-sslsocket branch from 2a4f5d2 to f4af45c Compare February 22, 2018 17:39
* The SSLSocket is no longer implemented on top of SSLObject to
  avoid an extra level of indirection.
* Owner and session are now handled in the internal constructor.
* _ssl._SSLSocket now uses the same method names as SSLSocket and
  SSLObject.
* Channel binding type check is now handled in C code. Channel binding
  is always available.

The patch also changes the signature of SSLObject.__init__(). In my
opinion it's fine. A SSLObject is not a user-constructable object.
SSLContext.wrap_bio() is the only valid factory.
@tiran tiran force-pushed the bpo-24334-simplify-sslsocket branch from f4af45c to 9a5cfc5 Compare February 24, 2018 19:52
@tiran tiran merged commit 141c5e8 into python:master Feb 24, 2018
@miss-islington
Copy link
Contributor

Thanks @tiran for the PR 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

@bedevere-bot
Copy link

@tiran: Please replace # with GH- in the commit message next time. Thanks!

@tiran tiran deleted the bpo-24334-simplify-sslsocket branch February 24, 2018 20:11
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 24, 2018
* The SSLSocket is no longer implemented on top of SSLObject to
  avoid an extra level of indirection.
* Owner and session are now handled in the internal constructor.
* _ssl._SSLSocket now uses the same method names as SSLSocket and
  SSLObject.
* Channel binding type check is now handled in C code. Channel binding
  is always available.

The patch also changes the signature of SSLObject.__init__(). In my
opinion it's fine. A SSLObject is not a user-constructable object.
SSLContext.wrap_bio() is the only valid factory.
(cherry picked from commit 141c5e8)

Co-authored-by: Christian Heimes <[email protected]>
@bedevere-bot
Copy link

GH-5857 is a backport of this pull request to the 3.7 branch.

tiran added a commit that referenced this pull request Feb 24, 2018
* The SSLSocket is no longer implemented on top of SSLObject to
  avoid an extra level of indirection.
* Owner and session are now handled in the internal constructor.
* _ssl._SSLSocket now uses the same method names as SSLSocket and
  SSLObject.
* Channel binding type check is now handled in C code. Channel binding
  is always available.

The patch also changes the signature of SSLObject.__init__(). In my
opinion it's fine. A SSLObject is not a user-constructable object.
SSLContext.wrap_bio() is the only valid factory.
(cherry picked from commit 141c5e8)

Co-authored-by: Christian Heimes <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants