You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ok, it came to me that converting to one of the PROTOCOL* constants can fail in the following case: Python is linked with an OpenSSL that supports a more recent protocol version than the ssl module is aware of. SSL_get_version() can then return a protocol (e.g. "TLSv1.3") that we don't know about, and have no way of converting to an existing constant.
So perhaps we should really simply return the same string as OpenSSL?
Debatable. Maybe I'm +0.1 for returning the plain string. IMO when it comes to stdlib modules, enums are only really useful for converting integer constants.
Attached patch backports it (only change is the use of closing() and resolving the conflict in Misc/NEWS). I'll leave it up to benjamin whether he wants to commit (input from others welcome). My view is to prefer backporting stuff since it helps keep the diff small.
Activity
pitrou commentedon Jan 28, 2014
SSL sockets should provide a way to query the current protocol version (e.g. "TLSv1.2"). OpenSSL makes it easy through SSL_get_version().
Open question is whether we return the string returned by SSL_get_version(), or we convert it to one of the constants ssl.PROTOCOL_XXX.
pitrou commentedon Mar 23, 2014
(slightly related: should ssl.PROTOCOL_xxx constants become enum members?)
pitrou commentedon Mar 25, 2014
We could actually use the undocumented "int SSL_version(const SSL *s)" and convert the return value to one of our favourite protocol constants.
ethanfurman commentedon Apr 16, 2014
Sounds good to me.
pitrou commentedon Apr 18, 2014
Ok, it came to me that converting to one of the PROTOCOL* constants can fail in the following case: Python is linked with an OpenSSL that supports a more recent protocol version than the ssl module is aware of. SSL_get_version() can then return a protocol (e.g. "TLSv1.3") that we don't know about, and have no way of converting to an existing constant.
So perhaps we should really simply return the same string as OpenSSL?
giampaolo commentedon Apr 18, 2014
Debatable. Maybe I'm +0.1 for returning the plain string. IMO when it comes to stdlib modules, enums are only really useful for converting integer constants.
pitrou commentedon Aug 23, 2014
Here is a patch. Doc updates still missing.
pitrou commentedon Aug 30, 2014
Updated patch with doc.
python-dev commentedon Sep 4, 2014
New changeset 648685f8d5e9 by Antoine Pitrou in branch 'default':
Issue bpo-20421: Add a .version() method to SSL sockets exposing the actual protocol version in use.
http://hg.python.org/cpython/rev/648685f8d5e9
pitrou commentedon Sep 4, 2014
Pushed to default.
alex commentedon Sep 4, 2014
Should this be backported to 2.7.9?
pitrou commentedon Sep 4, 2014
It's as you want, now. I don't think this is really important, though.
alex commentedon Sep 4, 2014
Attached patch backports it (only change is the use of
closing()and resolving the conflict in Misc/NEWS). I'll leave it up to benjamin whether he wants to commit (input from others welcome). My view is to prefer backporting stuff since it helps keep the diff small.python-dev commentedon Sep 4, 2014
New changeset 16c86a6bdbe2 by Alex Gaynor in branch '2.7':
Issue bpo-20421: Add a .version() method to SSL sockets exposing the actual protocol version in use.
http://hg.python.org/cpython/rev/16c86a6bdbe2