Merge pull request #36 from dod-ccpo/validate-certs

turn off service SSL cert validation by default for development
This commit is contained in:
dandds 2018-06-18 14:34:36 -04:00 committed by GitHub
commit b622572cdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -5,9 +5,10 @@ from json import dumps, loads
class ApiClient(object):
def __init__(self, base_url):
def __init__(self, base_url, validate_cert=True):
self.base_url = base_url
self.client = AsyncHTTPClient()
self.validate_cert = validate_cert
@tornado.gen.coroutine
def get(self, path, **kwargs):
@ -35,6 +36,8 @@ class ApiClient(object):
headers = kwargs.get('headers', {})
headers['Content-Type'] = 'application/json'
kwargs['headers'] = headers
if not 'validate_cert' in kwargs:
kwargs['validate_cert'] = self.validate_cert
response = yield self.client.fetch(url, method=method, **kwargs)
return self.adapt_response(response)

View File

@ -69,10 +69,12 @@ def make_app(config, deps, **kwargs):
def make_deps(config):
# we do not want to do SSL verify services in test and development
validate_cert = ENV == 'production'
return {
'authz_client': ApiClient(config["default"]["AUTHZ_BASE_URL"]),
'authnid_client': ApiClient(config["default"]["AUTHNID_BASE_URL"]),
'requests_client': ApiClient(config["default"]["REQUESTS_QUEUE_BASE_URL"])
'authz_client': ApiClient(config["default"]["AUTHZ_BASE_URL"], validate_cert=validate_cert),
'authnid_client': ApiClient(config["default"]["AUTHNID_BASE_URL"], validate_cert=validate_cert),
'requests_client': ApiClient(config["default"]["REQUESTS_QUEUE_BASE_URL"], validate_cert=validate_cert)
}