Skip to content

Commit

Permalink
Merge pull request #293 from qistoph/sni
Browse files Browse the repository at this point in the history
Set SNI to Host header in HostHeaderSSLAdapter
  • Loading branch information
sigmavirus24 authored Aug 11, 2023
2 parents 7685b15 + 9b39776 commit c5ac5f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
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)

0 comments on commit c5ac5f3

Please sign in to comment.