-
Notifications
You must be signed in to change notification settings - Fork 419
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
Add support for querying the negotiated TLS version. The Quickening #244
Changes from 16 commits
5d85fca
ba65e66
b296792
06bbba1
380507e
2637c3b
3cd0e67
85a4dff
5230dad
f00513f
abff188
d382d6d
d1c896e
a923e93
208438c
58d2573
b5b6b0e
46f2891
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
2015-05-27 Jim Shaver <[email protected]> | ||
|
||
* OpenSSL/SSL.py, : Add ``get_protocol_version()`` and | ||
``get_protocol_version_name()`` to ``Connection``. | ||
Based on work from Rich Moore. | ||
|
||
2015-05-02 Jim Shaver <[email protected]> | ||
|
||
* .travis.yml, setup.py, tox.ini: Removed support for Python 3.2. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1883,6 +1883,31 @@ def get_cipher_version(self): | |
return version.decode("utf-8") | ||
|
||
|
||
def get_protocol_version_name(self): | ||
""" | ||
Obtain the protocol version of the current connection. | ||
|
||
:returns: The TLS version of the current connection, for example | ||
the value for TLS 1.2 would be ``TLSv1.2``or ``Unknown`` | ||
for connections that were not successfully. | ||
:rtype: :py:class:`unicode` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that’s not true anymore? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 208438c now bytes |
||
""" | ||
version = _ffi.string(_lib.SSL_get_version(self._ssl)) | ||
return version.decode("utf-8") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I’m not sure about this one. I believe we decided to keep pyOpenSSL’s APIs bytes-based except for paths. So unless someone can enlighten me on what I’m missing, I’m gonna claim this ought to be bytes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dunno, the name of the protocol version definitely seems textual to me. On Mon, Apr 27, 2015 at 10:16 AM, Hynek Schlawack [email protected]
"I disapprove of what you say, but I will defend to the death your right to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand your argument correctly, you are saying that when you query for TLS version you should receive something like 0x769 as a response? The whole python3 bytes v. unicode thing is still new to me... What was the thinking behind trying to stick with bytes? Plenty of things in SSL.py are unicode strings though, including much of the related cipher information. Should a developer really have to get out their OpenSSL decoder ring everytime she wants to query a cipher? I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For the first paragraph; what I’m saying is that the docstring is plain wrong. There’s no way you get anything resembling “0x303” back. You get a string like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
|
||
def get_protocol_version(self): | ||
""" | ||
Obtain the protocol version of the current connection. | ||
|
||
:returns: The TLS version of the current connection, for example | ||
the value for TLS 1 would be 0x769. | ||
:rtype: :py:class:`int` | ||
""" | ||
version = _lib.SSL_version(self._ssl) | ||
return version | ||
|
||
|
||
@_requires_npn | ||
def get_next_proto_negotiated(self): | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -598,6 +598,20 @@ Connection objects have the following methods: | |
but not it returns the entire list in one go. | ||
|
||
|
||
.. py:method:: Connection.get_protocol_version() | ||
|
||
Retrieve the version of the SSL or TLS protocol used by the Connection. | ||
For example, it will return ``0x769`` for connections made over TLS | ||
version 1. | ||
|
||
|
||
.. py:method:: Connection.get_protocol_version_name() | ||
|
||
Retrieve the version of the SSL or TLS protocol used by the Connection. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. “…as an unicode string.” would be nice to differentiate it from the other method, no? |
||
For example, it will return ``TLSv1`` for connections made over TLS version | ||
1, or ``Unknown`` for connections that were not successfully established. | ||
|
||
|
||
.. py:method:: Connection.get_client_ca_list() | ||
|
||
Retrieve the list of preferred client certificate issuers sent by the server | ||
|
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.
successfully what?