Repository: docker/docker-py

Issue:
SSLAdapter init_poolmanager error because request.packages.urllib3.__version__ invalid
In ssladapter.py, 

``` python
try:
    import requests.packages.urllib3 as urllib3
except ImportError:
    import urllib3
...

        if urllib3 and urllib_ver == 'dev' and \
           StrictVersion(urllib_ver) > StrictVersion('1.5'):
            kwargs['ssl_version'] = self.ssl_version

        self.poolmanager = PoolManager(**kwargs)
```

`requests.packages.urllib3` will be imported, and the `requests.packages.urllib3.__version__` is 'dev' at present, and the `StrictVersion(urllib_ver)` will raise a ValueError: "invalid version number 'dev'"



Discussion:

Resolving patch:
diff --git a/docker/ssladapter/ssladapter.py b/docker/ssladapter/ssladapter.py
--- a/docker/ssladapter/ssladapter.py
+++ b/docker/ssladapter/ssladapter.py
@@ -15,19 +15,27 @@
 
 class SSLAdapter(HTTPAdapter):
     '''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
-    def __init__(self, ssl_version=None, **kwargs):
+    def __init__(self, ssl_version=None, assert_hostname=None, **kwargs):
         self.ssl_version = ssl_version
+        self.assert_hostname = assert_hostname
         super(SSLAdapter, self).__init__(**kwargs)
 
     def init_poolmanager(self, connections, maxsize, block=False):
-        urllib_ver = urllib3.__version__.split('-')[0]
         kwargs = {
             'num_pools': connections,
             'maxsize': maxsize,
-            'block': block
+            'block': block,
+            'assert_hostname': self.assert_hostname,
         }
-        if urllib3 and urllib_ver == 'dev' and \
-           StrictVersion(urllib_ver) > StrictVersion('1.5'):
+        if self.can_override_ssl_version():
             kwargs['ssl_version'] = self.ssl_version
 
         self.poolmanager = PoolManager(**kwargs)
+
+    def can_override_ssl_version(self):
+        urllib_ver = urllib3.__version__.split('-')[0]
+        if urllib_ver is None:
+            return False
+        if urllib_ver == 'dev':
+            return True
+        return StrictVersion(urllib_ver) > StrictVersion('1.5')
diff --git a/docker/tls.py b/docker/tls.py
--- a/docker/tls.py
+++ b/docker/tls.py
@@ -10,7 +10,7 @@ class TLSConfig(object):
     ssl_version = None
 
     def __init__(self, client_cert=None, ca_cert=None, verify=None,
-                 ssl_version=None):
+                 ssl_version=None, assert_hostname=None):
         # Argument compatibility/mapping with
         # http://docs.docker.com/examples/https/
         # This diverges from the Docker CLI in that users can specify 'tls'
@@ -20,6 +20,7 @@ def __init__(self, client_cert=None, ca_cert=None, verify=None,
         # urllib3 sets a default ssl_version if ssl_version is None
         # http://tinyurl.com/kxga8hb
         self.ssl_version = ssl_version
+        self.assert_hostname = assert_hostname
 
         # "tls" and "tls_verify" must have both or neither cert/key files
         # In either case, Alert the user when both are expected, but any are
@@ -65,4 +66,7 @@ def configure_client(self, client):
             client.verify = self.verify
         if self.cert:
             client.cert = self.cert
-        client.mount('https://', ssladapter.SSLAdapter(self.ssl_version))
+        client.mount('https://', ssladapter.SSLAdapter(
+            ssl_version=self.ssl_version,
+            assert_hostname=self.assert_hostname,
+        ))


Test patch: