Implement AsyncOpenSearch() parameter ssl_assert_hostname (#843)

* Implement AsyncOpenSearch() parameter `ssl_assert_hostname` to allow disabling SSL hostname verification

Signed-off-by: merlinz01 <[email protected]>

* Update PR link

Signed-off-by: merlinz01 <[email protected]>

* Add test

Signed-off-by: merlinz01 <[email protected]>

* Update docs

Signed-off-by: merlinz01 <[email protected]>

* Add test for default value

Signed-off-by: merlinz01 <[email protected]>

* Fix formatting

Signed-off-by: merlinz01 <[email protected]>

* Fix test failing on Python >3.12.7

Signed-off-by: merlinz01 <[email protected]>

* Fix formatting

Signed-off-by: merlinz01 <[email protected]>

---------

Signed-off-by: merlinz01 <[email protected]>
Signed-off-by: Daniel (dB.) Doubrovkine <[email protected]>
Co-authored-by: Daniel (dB.) Doubrovkine <[email protected]>
This commit is contained in:
Merlin
2024-11-16 08:29:10 -05:00
committed by GitHub
co-authored by Daniel Doubrovkine
parent 1269cdc95a
commit 12c379d32d
6 changed files with 39 additions and 7 deletions
+5 -3
View File
@@ -109,7 +109,7 @@ class AsyncOpenSearch(Client):
])
If using SSL, there are several parameters that control how we deal with
certificates (see :class:`~opensearchpy.Urllib3HttpConnection` for
certificates (see :class:`~opensearchpy.AIOHttpConnection` for
detailed description of the options)::
client = OpenSearch(
@@ -123,7 +123,7 @@ class AsyncOpenSearch(Client):
)
If using SSL, but don't verify the certs, a warning message is showed
optionally (see :class:`~opensearchpy.Urllib3HttpConnection` for
optionally (see :class:`~opensearchpy.AIOHttpConnection` for
detailed description of the options)::
client = OpenSearch(
@@ -132,12 +132,14 @@ class AsyncOpenSearch(Client):
use_ssl=True,
# no verify SSL certificates
verify_certs=False,
# don't verify the hostname in the certificate
ssl_assert_hostname=False,
# don't show warnings about ssl certs verification
ssl_show_warn=False
)
SSL client authentication is supported
(see :class:`~opensearchpy.Urllib3HttpConnection` for
(see :class:`~opensearchpy.AIOHttpConnection` for
detailed description of the options)::
client = OpenSearch(
+2 -1
View File
@@ -85,6 +85,7 @@ class AIOHttpConnection(AsyncConnection):
client_cert: Any = None,
client_key: Any = None,
ssl_version: Any = None,
ssl_assert_hostname: bool = True,
ssl_assert_fingerprint: Any = None,
maxsize: Optional[int] = 10,
headers: Any = None,
@@ -178,7 +179,7 @@ class AIOHttpConnection(AsyncConnection):
if verify_certs:
ssl_context.verify_mode = ssl.CERT_REQUIRED
ssl_context.check_hostname = True
ssl_context.check_hostname = ssl_assert_hostname
else:
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE