Add support for querying the negotiated TLS version.
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py
index e67bd13..2ee0512 100644
--- a/OpenSSL/SSL.py
+++ b/OpenSSL/SSL.py
@@ -1938,6 +1938,17 @@
return _ffi.buffer(data[0], data_len[0])[:]
+ 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.2 would be 0x303.
+ :rtype: :py:class:`int`
+ """
+ version = _lib.SSL_version(self._ssl)
+ return version
+
ConnectionType = Connection
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index 1f231c9..7605dc0 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -2745,6 +2745,20 @@
self.assertEqual(server_cipher_bits, client_cipher_bits)
+ def test_get_protocol_version(self):
+ """
+ :py:obj:`Connection.get_protocol_version` returns a :py:class:`int`
+ giving the protocol version of the current connection.
+ """
+ server, client = self._loopback()
+ server_protocol_version, client_protocol_version = \
+ server.get_protocol_version(), client.get_protocol_version()
+
+ self.assertIsInstance(server_protocol_version, int)
+ self.assertIsInstance(client_protocol_version, int)
+
+ self.assertEqual(server_protocol_version, client_protocol_version)
+
class ConnectionGetCipherListTests(TestCase):
"""
diff --git a/setup.py b/setup.py
index f742c1e..c43a1d9 100755
--- a/setup.py
+++ b/setup.py
@@ -46,6 +46,7 @@
raise RuntimeError("Unable to find __{meta}__ string.".format(meta=meta))
+<<<<<<< HEAD
class PyTest(TestCommand):
user_options = [("pytest-args=", "a", "Arguments to pass to py.test")]
@@ -78,6 +79,41 @@
url=find_meta("uri"),
license=find_meta("license"),
classifiers=[
+=======
+# XXX Deduplicate this
+__version__ = '0.14'
+
+setup(name='pyOpenSSL', version=__version__,
+ packages = ['OpenSSL'],
+ package_dir = {'OpenSSL': 'OpenSSL'},
+ py_modules = ['OpenSSL.__init__',
+ 'OpenSSL.tsafe',
+ 'OpenSSL.rand',
+ 'OpenSSL.crypto',
+ 'OpenSSL.SSL',
+ 'OpenSSL.version',
+ 'OpenSSL.test.__init__',
+ 'OpenSSL.test.util',
+ 'OpenSSL.test.test_crypto',
+ 'OpenSSL.test.test_rand',
+ 'OpenSSL.test.test_ssl'],
+ description = 'Python wrapper module around the OpenSSL library',
+ author = 'Jean-Paul Calderone',
+ author_email = 'exarkun@twistedmatrix.com',
+ maintainer = 'Jean-Paul Calderone',
+ maintainer_email = 'exarkun@twistedmatrix.com',
+ url = 'https://github.com/pyca/pyopenssl',
+ license = 'APL2',
+ install_requires=["cryptography>=0.7.2", "six>=1.5.2"],
+ long_description = """\
+High-level wrapper around a subset of the OpenSSL library, includes
+ * SSL.Connection objects, wrapping the methods of Python's portable
+ sockets
+ * Callbacks written in Python
+ * Extensive error-handling mechanism, mirroring OpenSSL's error codes
+... and much more ;)""",
+ classifiers = [
+>>>>>>> Add support for querying the negotiated TLS version.
'Development Status :: 6 - Mature',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',