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

Set SNI to Host header in HostHeaderSSLAdapter #293

Merged
merged 2 commits into from
Aug 11, 2023
Merged
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: 3 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ Patches and Suggestions

- Sam Bull (@greatestape)

- Florence Blanc-Renaud <[email protected]> (@flo-renaud)
- Chris van Marle (https://github.com/qistoph)

- Florence Blanc-Renaud <[email protected]> (@flo-renaud)
4 changes: 4 additions & 0 deletions docs/adapters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ Requests supports SSL Verification by default. However, it relies on
the user making a request with the URL that has the hostname in it. If,
however, the user needs to make a request with the IP address, they cannot
actually verify a certificate against the hostname they want to request.
This adapter sets the `Server Name Indication`_ to, and verifies the
certificate against, the hostname in the Host header.

To accomodate this very rare need, we've added
:class:`~requests_toolbelt.adapters.host_header_ssl.HostHeaderSSLAdapter`.
Expand All @@ -92,6 +94,8 @@ Example usage:

.. autoclass:: requests_toolbelt.adapters.host_header_ssl.HostHeaderSSLAdapter

.. _Server Name Indication: https://en.wikipedia.org/wiki/Server_Name_Indication

SourceAddressAdapter
--------------------

Expand Down
2 changes: 2 additions & 0 deletions requests_toolbelt/adapters/host_header_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def send(self, request, **kwargs):

if host_header:
connection_pool_kwargs["assert_hostname"] = host_header
connection_pool_kwargs["server_hostname"] = host_header
elif "assert_hostname" in connection_pool_kwargs:
# an assert_hostname from a previous request may have been left
connection_pool_kwargs.pop("assert_hostname", None)
connection_pool_kwargs.pop("server_hostname", None)

return super(HostHeaderSSLAdapter, self).send(request, **kwargs)
Loading