Skip to content
Myr

Updated Requests api to accept a 'cert' argument.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This argument can be either a string, containing the path to a pem-formatted key and certificate chain, or a tuple of (cert, key). When supplied a tuple, the values are paths to an SSL certificate chain file and key, respectively.

authored by chadnickbok@gmail.com · committed by chadnickbok@gmail.com · parent 82e69de · Browse files · 3 files+17 added−19 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+17 added−19 removed

  • other:+17 added−19 removed

3 files+17 added−19 removed

modified:requests/api.py+1 added-2 removed
31 unmodified lines
32 :param session: (optional) A :class:`Session` object to be used for the request.33 :param config: (optional) A configuration dictionary.34 :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided.35 :param prefetch: (optional) if ``True``, the response content will be immediately downloaded.36 :param key_file: (optional) ssl client key file.37 :param cert_file: (optional) ssl client cert file.36 :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.37 """3839 s = kwargs.pop('session') if 'session' in kwargs else sessions.session()40 return s.request(method=method, url=url, **kwargs)
77 unmodified lines
modified:requests/models.py+10 added-8 removed
62 unmodified lines
63 config=None,64 _poolmanager=None,65 verify=None,66 session=None,67 key_file=None,68 cert_file=None):67 cert=None):6869 #: Dictionary of configurations for this request.70 self.config = dict(config or [])71
72 unmodified lines
144 #: SSL Verification.145 self.verify = verify146147 #: SSL Certificate149 self.key_file = key_file150 self.cert_file = cert_file148 self.cert = cert149150 if headers:151 headers = CaseInsensitiveDict(self.headers)152 else:
117 unmodified lines
270 timeout=self.timeout,271 _poolmanager=self._poolmanager,272 proxies=self.proxies,273 verify=self.verify,276 session=self.session274 session=self.session,275 cert=self.cert276 )277278 request.send()279 r = request.response
231 unmodified lines
511 else:512 conn.cert_reqs = 'CERT_NONE'513 conn.ca_certs = None514516 if self.key_file and self.cert_file:517 conn.key_file = self.key_file518 conn.cert_file = self.cert_file515 if self.cert:516 if type(self.cert) is tuple:517 conn.cert_file = self.cert[0]518 conn.key_file = self.cert[1]519 else:520 conn.cert_file = self.cert521522 if not self.sent or anyway:523524 if self.cookies:
304 unmodified lines
modified:requests/sessions.py+6 added-9 removed
62 unmodified lines
63 """A Requests session."""6465 __attrs__ = [66 'headers', 'cookies', 'auth', 'timeout', 'proxies', 'hooks',67 'params', 'config', 'verify']67 'params', 'config', 'verify', 'cert']686970 def __init__(self,71 headers=None,
5 unmodified lines
77 params=None,78 config=None,79 prefetch=False,80 verify=True,81 key_file=None,82 cert_file=None):81 cert=None):8283 self.headers = headers or {}84 self.cookies = cookies or {}85 self.auth = auth
3 unmodified lines
89 self.params = params or {}90 self.config = config or {}91 self.prefetch = prefetch92 self.verify = verify94 self.key_file = key_file95 self.cert_file = cert_file93 self.cert = cert9495 for (k, v) in list(defaults.items()):96 self.config.setdefault(k, v)97
35 unmodified lines
133 return_response=True,134 config=None,135 prefetch=False,136 verify=None,139 key_file=None,140 cert_file=None):137 cert=None):138139 """Constructs and sends a :class:`Request <Request>`.140 Returns :class:`Response <Response>` object.141
11 unmodified lines
153 :param return_response: (optional) If False, an un-sent Request object will returned.154 :param config: (optional) A configuration dictionary.155 :param prefetch: (optional) if ``True``, the response content will be immediately downloaded.156 :param verify: (optional) if ``True``, the SSL cert will be verified. A CA_BUNDLE path can also be provided.157 :param cert: (optional) if String, path to ssl client cert file (.pem). If Tuple, ('cert', 'key') pair.158 """159160 method = str(method).upper()161
29 unmodified lines
191 allow_redirects=allow_redirects,192 proxies=proxies,193 config=config,194 verify=verify,197 key_file=key_file,198 cert_file=cert_file,195 cert=cert,196 _poolmanager=self.poolmanager197 )198199 # Merge local kwargs with session kwargs.
118 unmodified lines