-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Prohibit direct instantiation of SSLSocket and SSLObject #77132
Comments
The constructors of SSLObject and SSLSocket were never documented, tested, or meant to be used directly. Instead users were suppose to use ssl.wrap_socket or an SSLContext object. The ssl.wrap_socket() function and direct instantiation of SSLSocket has multiple issues. From my mail "No hostname matching with ssl.wrap_socket() and SSLSocket() constructor" to PSRT: The ssl module has three ways to create a
Variant (1) and (2) are old APIs with insecure default settings. Variant (3) is the new and preferred way. With While Martin Panter was reviewing my documentation improvements for the However ssl.SSLSocket() constructor and ssl.wrap_socket() have more --- import socket
import ssl
cafile = ssl.get_default_verify_paths().cafile
with socket.socket() as sock:
ssock = ssl.SSLSocket(
sock,
cert_reqs=ssl.CERT_REQUIRED,
ca_certs=cafile,
server_hostname='www.python.org'
)
ssock.connect(('www.evil.com', 443)) I don't see a way to fix the issue in a secure way while keeping By the way, SSLObject is sane because it always goes through Regards, [1] https://docs.python.org/3/library/ssl.html#ssl.wrap_socket |
Antoine Pitrou replied: The ssl.SSLSocket constructor was never meant to be called by user ssl.wrap_socket() is essentially a legacy API. I would suggest the following measures :
--- If SSLSocket.__init__ is meant to be private and not called by users, It'd break anyone who was relying on it, but they weren't supposed to be --- I have implemented Antoine's second proposal in bpo-28124. |
Can this issue be closed as resolved? |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: