Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python] Allow clients to define TLS Server name (SNI) (aiohttp) #16380

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class RESTClientObject:
configuration.cert_file, keyfile=configuration.key_file
)

self.server_hostname = configuration.tls_server_name

if not configuration.verify_ssl:
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
Expand Down Expand Up @@ -122,6 +124,9 @@ class RESTClientObject:
if query_params:
args["url"] += '?' + urlencode(query_params)

if self.server_hostname:
args["server_hostname"] = self.server_hostname

# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
if re.search('json', headers['Content-Type'], re.IGNORECASE):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def __init__(self, configuration, pools_size=4, maxsize=None) -> None:
configuration.cert_file, keyfile=configuration.key_file
)

self.server_hostname = configuration.tls_server_name

if not configuration.verify_ssl:
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
Expand Down Expand Up @@ -132,6 +134,9 @@ async def request(self, method, url, query_params=None, headers=None,
if query_params:
args["url"] += '?' + urlencode(query_params)

if self.server_hostname:
args["server_hostname"] = self.server_hostname

# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
if re.search('json', headers['Content-Type'], re.IGNORECASE):
Expand Down