Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow user to set not to verify SSL certificate on request #1

Closed
wants to merge 1 commit into from
Closed
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
7 changes: 5 additions & 2 deletions openqa_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
class OpenQA_Client(object):
"""A client for the OpenQA REST API; just handles API auth if
needed and provides a couple of custom methods for convenience."""
def __init__(self, server=''):
def __init__(self, server='', verify=True):
# Read in config files.
config = configparser.ConfigParser()
paths = ('/etc/openqa',
Expand Down Expand Up @@ -77,6 +77,9 @@ def __init__(self, server=''):
headers['X-API-Key'] = apikey
self.session.headers.update(headers)

# Allow/forbid SSL certificate verification
self.verify = verify

def _add_auth_headers(self, request):
"""Add authentication headers to a PreparedRequest. See
openQA/lib/OpenQA/client.pm for the authentication design.
Expand All @@ -101,7 +104,7 @@ def do_request(self, request):
something unusual."""
prepared = self.session.prepare_request(request)
authed = self._add_auth_headers(prepared)
resp = self.session.send(authed)
resp = self.session.send(authed, verify=self.verify)
return resp.json()

def openqa_request(self, method, path, params={}):
Expand Down