switch to SSL_get_version.
diff --git a/OpenSSL/SSL.py b/OpenSSL/SSL.py
index 2ee0512..28e5199 100644
--- a/OpenSSL/SSL.py
+++ b/OpenSSL/SSL.py
@@ -1883,6 +1883,18 @@
return version.decode("utf-8")
+ 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_get_version(self._ssl)
+ return version
+
+
@_requires_npn
def get_next_proto_negotiated(self):
"""
diff --git a/OpenSSL/test/test_ssl.py b/OpenSSL/test/test_ssl.py
index 7605dc0..83d9896 100644
--- a/OpenSSL/test/test_ssl.py
+++ b/OpenSSL/test/test_ssl.py
@@ -2747,15 +2747,15 @@
def test_get_protocol_version(self):
"""
- :py:obj:`Connection.get_protocol_version` returns a :py:class:`int`
+ :py:obj:`Connection.get_protocol_version` returns a string
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.assertIsInstance(server_protocol_version, text_type)
+ self.assertIsInstance(client_protocol_version, text_type)
self.assertEqual(server_protocol_version, client_protocol_version)
diff --git a/setup.py b/setup.py
index c43a1d9..3f1dbf2 100755
--- a/setup.py
+++ b/setup.py
@@ -46,7 +46,6 @@
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")]
@@ -79,41 +78,6 @@
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',
@@ -132,6 +96,7 @@
'Topic :: Security :: Cryptography',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Networking',
+<<<<<<< HEAD
],
packages=['OpenSSL'],
@@ -161,3 +126,14 @@
"test": PyTest,
}
)
+=======
+ ],
+ test_suite="OpenSSL",
+ tests_require=[
+ "pytest",
+ ],
+ cmdclass={
+ "test": PyTest,
+ })
+
+>>>>>>> switch to SSL_get_version.