mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
Improve assert_hostname setting in tls_config_from_options
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
26f3861791
commit
442dff72b4
@ -8,6 +8,7 @@ from docker import Client
|
|||||||
from docker.errors import TLSParameterError
|
from docker.errors import TLSParameterError
|
||||||
from docker.tls import TLSConfig
|
from docker.tls import TLSConfig
|
||||||
from docker.utils import kwargs_from_env
|
from docker.utils import kwargs_from_env
|
||||||
|
from requests.utils import urlparse
|
||||||
|
|
||||||
from ..const import HTTP_TIMEOUT
|
from ..const import HTTP_TIMEOUT
|
||||||
from .errors import UserError
|
from .errors import UserError
|
||||||
@ -21,6 +22,7 @@ def tls_config_from_options(options):
|
|||||||
cert = options.get('--tlscert')
|
cert = options.get('--tlscert')
|
||||||
key = options.get('--tlskey')
|
key = options.get('--tlskey')
|
||||||
verify = options.get('--tlsverify')
|
verify = options.get('--tlsverify')
|
||||||
|
hostname = urlparse(options.get('--host', '')).hostname
|
||||||
|
|
||||||
advanced_opts = any([ca_cert, cert, key, verify])
|
advanced_opts = any([ca_cert, cert, key, verify])
|
||||||
|
|
||||||
@ -32,7 +34,9 @@ def tls_config_from_options(options):
|
|||||||
client_cert = (cert, key)
|
client_cert = (cert, key)
|
||||||
return TLSConfig(
|
return TLSConfig(
|
||||||
client_cert=client_cert, verify=verify, ca_cert=ca_cert,
|
client_cert=client_cert, verify=verify, ca_cert=ca_cert,
|
||||||
assert_hostname=options.get('--skip-hostname-check')
|
assert_hostname=(
|
||||||
|
hostname or not options.get('--skip-hostname-check', False)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user