Skip to content

Commit 4bf438d

Browse files
committed
Enable the overriding of assert_hostname on TLSConfig
Signed-off-by: Aanand Prasad <[email protected]>
1 parent 7db976c commit 4bf438d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

docker/ssladapter/ssladapter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,17 @@
1515

1616
class SSLAdapter(HTTPAdapter):
1717
'''An HTTPS Transport Adapter that uses an arbitrary SSL version.'''
18-
def __init__(self, ssl_version=None, **kwargs):
18+
def __init__(self, ssl_version=None, assert_hostname=None, **kwargs):
1919
self.ssl_version = ssl_version
20+
self.assert_hostname = assert_hostname
2021
super(SSLAdapter, self).__init__(**kwargs)
2122

2223
def init_poolmanager(self, connections, maxsize, block=False):
2324
kwargs = {
2425
'num_pools': connections,
2526
'maxsize': maxsize,
26-
'block': block
27+
'block': block,
28+
'assert_hostname': self.assert_hostname,
2729
}
2830
if self.can_override_ssl_version():
2931
kwargs['ssl_version'] = self.ssl_version

docker/tls.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TLSConfig(object):
1010
ssl_version = None
1111

1212
def __init__(self, client_cert=None, ca_cert=None, verify=None,
13-
ssl_version=None):
13+
ssl_version=None, assert_hostname=None):
1414
# Argument compatibility/mapping with
1515
# http://docs.docker.com/examples/https/
1616
# 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,
2020
# urllib3 sets a default ssl_version if ssl_version is None
2121
# http://tinyurl.com/kxga8hb
2222
self.ssl_version = ssl_version
23+
self.assert_hostname = assert_hostname
2324

2425
# "tls" and "tls_verify" must have both or neither cert/key files
2526
# In either case, Alert the user when both are expected, but any are
@@ -65,4 +66,7 @@ def configure_client(self, client):
6566
client.verify = self.verify
6667
if self.cert:
6768
client.cert = self.cert
68-
client.mount('https://', ssladapter.SSLAdapter(self.ssl_version))
69+
client.mount('https://', ssladapter.SSLAdapter(
70+
ssl_version=self.ssl_version,
71+
assert_hostname=self.assert_hostname,
72+
))

0 commit comments

Comments
 (0)