Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,16 @@ def kwargs_from_env(ssl_version=None, assert_hostname=None):
tls_verify = os.environ.get('DOCKER_TLS_VERIFY')
if tls_verify == '':
tls_verify = False
enable_tls = True
else:
tls_verify = tls_verify is not None
enable_tls = cert_path or tls_verify
enable_tls = cert_path or tls_verify
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in the case where DOCKER_TLS_VERIFY= we're changing from tls being enabled by default, to tls being disabled by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - this in accordance with what people reported in #984.


params = {}

if host:
params['base_url'] = (host.replace('tcp://', 'https://')
if enable_tls else host)
params['base_url'] = (
host.replace('tcp://', 'https://') if enable_tls else host
)

if not enable_tls:
return params
Expand Down
14 changes: 1 addition & 13 deletions tests/unit/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,19 +228,7 @@ def test_kwargs_from_env_tls_verify_false_no_cert(self):
DOCKER_TLS_VERIFY='')
os.environ.pop('DOCKER_CERT_PATH', None)
kwargs = kwargs_from_env(assert_hostname=True)
self.assertEqual('https://192.168.59.103:2376', kwargs['base_url'])
self.assertTrue('ca.pem' in kwargs['tls'].ca_cert)
self.assertTrue('cert.pem' in kwargs['tls'].cert[0])
self.assertTrue('key.pem' in kwargs['tls'].cert[1])
self.assertEqual(True, kwargs['tls'].assert_hostname)
self.assertEqual(False, kwargs['tls'].verify)
try:
client = Client(**kwargs)
self.assertEqual(kwargs['base_url'], client.base_url)
self.assertEqual(kwargs['tls'].cert, client.cert)
self.assertFalse(kwargs['tls'].verify)
except TypeError as e:
self.fail(e)
self.assertEqual('tcp://192.168.59.103:2376', kwargs['base_url'])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this test change it's not clear to me what the expected behaviour is supposed to be.

It seems like we're reverting part of the recent change, is that right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I tested that case locally with the docker CLI, and setting DOCKER_TLS_VERIFY to empty string and DOCKER_HOST to a TCP address let me connect to an unsecured daemon, so I believe this change is correct.


def test_kwargs_from_env_no_cert_path(self):
try:
Expand Down