From da3377771ca6b4f3d26d37d01a4a7a5e41066d0c Mon Sep 17 00:00:00 2001 From: Stephen Moore Date: Sun, 8 Nov 2015 12:17:18 +1100 Subject: [PATCH] Ensure assert_hostname is set on the pool connection If you have assert_hostname turned off and are using a proxy on your computer then assert_hostname wasn't being properly set on the pool connection and it was failing to connect to docker Signed-off-by: Stephen Moore --- docker/ssladapter/ssladapter.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docker/ssladapter/ssladapter.py b/docker/ssladapter/ssladapter.py index 3a70a916ce..b653b68a20 100644 --- a/docker/ssladapter/ssladapter.py +++ b/docker/ssladapter/ssladapter.py @@ -46,6 +46,19 @@ def init_poolmanager(self, connections, maxsize, block=False): self.poolmanager = PoolManager(**kwargs) + def get_connection(self, *args, **kwargs): + """ + Ensure assert_hostname is set correctly on our pool + + We already take care of a normal poolmanager via init_poolmanager + + But we still need to take care of when there is a proxy poolmanager + """ + conn = super(SSLAdapter, self).get_connection(*args, **kwargs) + if conn.assert_hostname != self.assert_hostname: + conn.assert_hostname = self.assert_hostname + return conn + def can_override_ssl_version(self): urllib_ver = urllib3.__version__.split('-')[0] if urllib_ver is None: