Skip to content
Open
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
4 changes: 4 additions & 0 deletions kubernetes/aio/client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ def __init__(self, configuration) -> None:
if configuration.disable_strict_ssl_verification:
self.ssl_context.verify_flags &= ~ssl.VERIFY_X509_STRICT

if (configuration.verify_ssl
and configuration.assert_hostname is not None):
self.ssl_context.check_hostname = bool(configuration.assert_hostname)

self.proxy = configuration.proxy
self.proxy_headers = configuration.proxy_headers

Expand Down
17 changes: 17 additions & 0 deletions kubernetes/aio/test/test_generated_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,23 @@ async def test_strict_tls_verification_can_be_disabled(self):
rest_client.ssl_context.verify_flags & ssl.VERIFY_X509_STRICT,
)

async def test_assert_hostname_false_disables_hostname_check(self):
self.configuration.assert_hostname = False

rest_client = RESTClientObject(self.configuration)

self.assertFalse(rest_client.ssl_context.check_hostname)
self.assertEqual(ssl.CERT_REQUIRED, rest_client.ssl_context.verify_mode)

async def test_assert_hostname_does_not_reenable_verification(self):
self.configuration.verify_ssl = False
self.configuration.assert_hostname = True

rest_client = RESTClientObject(self.configuration)

self.assertFalse(rest_client.ssl_context.check_hostname)
self.assertEqual(ssl.CERT_NONE, rest_client.ssl_context.verify_mode)

async def test_models_preserve_int_or_string_and_python_field_names(self):
port = V1ServicePort(port=80, target_port='https')

Expand Down