Skip to content
Open
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
11 changes: 7 additions & 4 deletions certsrv.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,23 @@ class Certsrv(object):
cafile: A PEM file containing the CA certificates that should be trusted.
timeout: The timeout to use against the CA server, in seconds.
The default is 30.

proxies: Dictionary of proxy server for post of get operations
{'http': 'http://foo.bar:3128', 'https': 'socks5://foo.bar:1080'}
The default is None
Note:
If you use a client certificate for authentication (auth_method=cert),
the username parameter should be the path to a certificate, and
the password parameter the path to a (unencrypted) private key.
"""

def __init__(self, server, username, password, auth_method="basic",
cafile=None, timeout=TIMEOUT):
cafile=None, timeout=TIMEOUT, proxies=None):

self.server = server
self.timeout = timeout
self.auth_method = auth_method
self.session = requests.Session()
self.proxies = proxies

if cafile:
self.session.verify = cafile
Expand Down Expand Up @@ -105,11 +108,11 @@ def _set_credentials(self, username, password):
self.session.auth = (username, password)

def _post(self, url, **kwargs):
response = self.session.post(url, timeout=self.timeout, **kwargs)
response = self.session.post(url, timeout=self.timeout, proxies=self.proxies, **kwargs)
return self._handle_response(response)

def _get(self, url, **kwargs):
response = self.session.get(url, timeout=self.timeout, **kwargs)
response = self.session.get(url, timeout=self.timeout, proxies=self.proxies, **kwargs)
return self._handle_response(response)

@staticmethod
Expand Down