Do not set assert_hostname / tls_hostname automatically in certain situations. (#1226) (#1227)

(cherry picked from commit 5ba7b555a0)
This commit is contained in:
Felix Fontein 2025-12-30 23:08:52 +01:00 committed by GitHub
parent d3be36c911
commit f54cb0ceed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 2 deletions

View File

@ -0,0 +1,2 @@
bugfixes:
- "modules and plugins using the Docker SDK for Python - do not automatically set ``tls_hostname`` when ``validate_certs=true`` for Docker SDK for Python 7.0.0+ (https://github.com/ansible-collections/community.docker/issues/1225, https://github.com/ansible-collections/community.docker/pull/1226)."

View File

@ -160,9 +160,10 @@ def get_connect_params(auth, fail_function):
# TLS with verification
tls_config = dict(
verify=True,
assert_hostname=auth['tls_hostname'],
fail_function=fail_function,
)
if auth["tls_hostname"] is not None:
tls_config["assert_hostname"] = auth["tls_hostname"]
if auth['cert_path'] and auth['key_path']:
tls_config['client_cert'] = (auth['cert_path'], auth['key_path'])
if auth['cacert_path']:
@ -327,7 +328,8 @@ class AnsibleDockerClientBase(Client):
use_ssh_client=self._get_value('use_ssh_client', params['use_ssh_client'], None, False, type='bool'),
)
update_tls_hostname(result)
if LooseVersion(docker_version) < LooseVersion("7.0.0b1"):
update_tls_hostname(result)
return result