Repository: smarter-travel-media/warthog

Issue:
Unsupported TLS versions
Turns out that even if you manage to use a different SSL version, still needs to supported by the Python `ssl` module. Who knew? To this end we're going to add the new `PROTOCOL_TLS` constant (effectively the same as `PROTOCOL_SSLv23`) and use that to allow negotiation between the LB and our ancient Python version.

Discussion:

Patch:
diff --git a/doc/source/changes.rst b/doc/source/changes.rst
index aa5b3f1..0c2907a 100644
--- a/doc/source/changes.rst
+++ b/doc/source/changes.rst
@@ -2,6 +2,16 @@ Changelog
 =========
 
 
+1.999.1 - 2017-04-06
+---------------------
+.. note::
+
+    This version is only meant to be used internally at SmarterTravel as a transition
+    step between two load balancers. As such, it is not available on PyPI.
+
+* Add support for new Python SSL constant ``PROTOCOL_TLS`` to allow negotiation of SSL
+  versions between the client and server.
+
 1.999.0 - 2017-04-05
 --------------------
 .. note::
diff --git a/warthog/__init__.py b/warthog/__init__.py
index 9af2178..6d1434b 100644
--- a/warthog/__init__.py
+++ b/warthog/__init__.py
@@ -14,4 +14,4 @@ warthog
 Simple client for A10 load balancers.
 """
 
-__version__ = '1.999.0'
+__version__ = '1.999.1'
diff --git a/warthog/ssl.py b/warthog/ssl.py
index dea969f..92b4b3d 100644
--- a/warthog/ssl.py
+++ b/warthog/ssl.py
@@ -22,7 +22,7 @@ SSL related constants used by Warthog
 
 PROTOCOL_SSLv3 = 1
 
-PROTOCOL_SSLv23 = 2
+PROTOCOL_TLS = PROTOCOL_SSLv23 = 2
 
 PROTOCOL_TLSv1 = 3
 


Test patch:
diff --git a/test/test_ssl.py b/test/test_ssl.py
index 9165683..1b3ebf3 100644
--- a/test/test_ssl.py
+++ b/test/test_ssl.py
@@ -21,6 +21,24 @@ def test_tls1_matches():
     assert ssl.PROTOCOL_TLSv1 == warthog.ssl.PROTOCOL_TLSv1
 
 
+def test_tls_matches_ssl23():
+    # New constant in Python 2.7.13 for negotiation of the highest
+    # supported protocol. Same value as the previous "negotiate"
+    # constant (SSLv23).
+    assert ssl.PROTOCOL_SSLv23 == warthog.ssl.PROTOCOL_TLS
+
+
+def test_tls_matches():
+    try:
+        # It's possible that we're running under an old version of Python
+        # and this constant doesn't exist (hence why warthog.ssl exists).
+        module_const = ssl.PROTOCOL_TLS
+    except AttributeError:
+        return
+
+    assert module_const == warthog.ssl.PROTOCOL_TLS
+
+    
 def test_tls1_1_matches():
     try:
         # It's possible that we're running under an old version of Python