Created
January 31, 2012 12:00
-
-
Save dpwiz/1710121 to your computer and use it in GitHub Desktop.
Using client certificate with requests library
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
# https://github.com/kennethreitz/requests/issues/30#issuecomment-3631717 | |
def with_cert(session, key, cert=None): | |
"Monkeypatch session pool manager with client cert stuff" | |
session.poolmanager = session.poolmanager.__class__( | |
key_file = key, | |
cert_file = cert or key, | |
**session.poolmanager.connection_pool_kw) | |
return session | |
# usage: | |
from requests import Session | |
with_cert(Session(), 'my_cert.pem').get('https://193.201.228.75/', verify=False).content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment