Created
May 5, 2022 01:08
-
-
Save sethmlarson/54d4e04921e9b772c53ae8fb1e9f8b5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ssl | |
import requests | |
from requests.adapters import HTTPAdapter | |
import truststore | |
class TruststoreAdapter(HTTPAdapter): | |
def init_poolmanager( | |
self, *args, **kwargs | |
): | |
ctx = truststore.SSLContext(ssl.PROTOCOL_TLS_CLIENT) | |
kwargs.setdefault("ssl_context", ctx) | |
return super().init_poolmanager( | |
*args, **pool_kwargs | |
) | |
session = requests.Session() | |
session.adapters["https"] = TruststoreAdapter | |
session.request("GET", "https://example.com") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment