This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Documentation for ssl.wrap_socket's ssl_version parameter is odd
Type: enhancement Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 3.6, Python 3.4, Python 3.5, Python 2.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: docs@python Nosy List: christian.heimes, docs@python, eric.smith
Priority: low Keywords:

Created on 2015-06-03 13:10 by eric.smith, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (6)
msg244742 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-06-03 13:10
The documentation for ssl.wrap_socket()'s ssl_version parameter says "ssl_version={see docs}". But as far as I can tell, there's no reason not to document it as PROTOCOL_SSLv23, since that's what it actually is in the code.

My use case is that I'm producing a utility function for an RFC-5804 Manage Sieve client, which implements starttls(). I want to expose most of wrap_sockets()'s parameters, and pass them in to ssl.wrap_socket() itself. In order to do so, I need to specify the default values to match wrap_socket(). But ssl_version's default isn't documented.

Is the reason to allow us to change the default in a bug fix release? If that's the case, I suggest creating a sentinel value, like ssl.DEFAULT_PROTOCOL, and have that be the documented default. Then I could declare my parameter as defaulting to ssl.DEFAULT_PROTOCOL, pass it in to ssl.wrap_socket(), and have it use the "current" default.

If that's a desirable solution, I'll happily write a patch. If so, it would just apply to 3.6, but if we just want to document the actual value of ssl_version, then it would apply to the versions I've selected.
msg244745 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-06-03 13:48
It occurs to me that None would also be a fine default, and probably the smarter choice.

Then wrap_socket could say:
if ssl_version is None:
  ssl_version = PROTOCOL_SSLv23

And we could change the default as needed, without being held to the actual value. And wrapper code, like mine, would declare a default of None and things would continue to work across versions.
msg244747 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2015-06-03 13:54
I'd like to deprecate ssl.wrap_socket() in favor of SSLContext.wrap_socket(). Libraries should rather accept a context than expose the awkward interface of ssl.wrap_socket(). A context object is far more powerful and easier to use.
msg244748 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2015-06-03 14:09

I'm currently planning and researching two SSL related PEPs. One PEP is about SSLContext.

I like to standardize a minimal interface for SSL context object, so libraries can deal with any abitrary SSL implementation. With just one small addition and an SSLContext ABC, every library could then support stdlib ssl, PyOpenSSL, GnuTLS, NSS, PyQT/PySide QSslSocket and even non-standard sockets like NSPR PRFileDesc and QTcpSocket.

My idea only works with a SSL context object. So I'm interested that people use the new feature rather then the old ssl.wrap_socket() function. :)
msg244750 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2015-06-03 14:14
I have a requirement to support 2.7.5, so SSLContext is currently a problem for me.

I realize that 2.7 could at best get a documentation change.
msg275046 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2016-09-08 15:24
OpenSSL 1.1.0 has deprecated all versions except TLS_METHOD and DTLS_METHOD. TLS_METHOD is the new name for auto-nego SSLv23_METHOD. Python 3.6 defaults to TLS_METHOD already. #27876 will add a better way to configure accepted versions.
Date User Action Args
2022-04-11 14:58:17adminsetgithub: 68560
2021-12-11 21:20:15eric.smithsetstatus: pending -> closed
resolution: out of date
stage: resolved
2016-09-08 15:24:04christian.heimessetstatus: open -> pending

messages: + msg275046
2015-06-03 14:14:05eric.smithsetmessages: + msg244750
2015-06-03 14:09:54christian.heimessetmessages: + msg244748
2015-06-03 13:54:25christian.heimessetmessages: + msg244747
2015-06-03 13:52:04christian.heimessetnosy: + christian.heimes
2015-06-03 13:48:18eric.smithsetmessages: + msg244745
2015-06-03 13:10:46eric.smithcreate