From 13e90a0ab5e296fb8cf21d09c666c06ed47a84c0 Mon Sep 17 00:00:00 2001 From: Thomas Herve Date: Wed, 3 Oct 2018 14:45:25 +0200 Subject: [PATCH] Properly pass the CA to requests We store the CA in request.cert, but it's not compatible with a cert. To pass the CA to requests, we need to set the verify argument. Change-Id: Id0f39e3253b1486db8ae2da3d7dc6c0fdb41062a --- tests/unit/transport/test_http.py | 6 ++---- zaqarclient/transport/http.py | 10 ++++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/unit/transport/test_http.py b/tests/unit/transport/test_http.py index 0246c0f3..218344c4 100644 --- a/tests/unit/transport/test_http.py +++ b/tests/unit/transport/test_http.py @@ -63,8 +63,7 @@ class TestHttpTransport(base.TestBase): params=final_params, headers=final_headers, data=None, - verify=True, - cert=None) + verify=True) @mock.patch.object(prequest.packages.urllib3.response.HTTPResponse, 'stream') @@ -91,8 +90,7 @@ class TestHttpTransport(base.TestBase): params=params, headers=final_headers, data=None, - verify=True, - cert=None) + verify=True) @mock.patch.object(prequest.packages.urllib3.response.HTTPResponse, 'stream') diff --git a/zaqarclient/transport/http.py b/zaqarclient/transport/http.py index 1860ac7d..7d9064a1 100644 --- a/zaqarclient/transport/http.py +++ b/zaqarclient/transport/http.py @@ -89,13 +89,19 @@ class HttpTransport(base.Transport): if osprofiler_web: headers.update(osprofiler_web.get_trace_id_headers()) + if request.verify: + if request.cert: + verify = request.cert + else: + verify = True + else: + verify = False resp = self.client.request(method, url=url, params=request.params, headers=headers, data=request.content, - verify=request.verify, - cert=request.cert) + verify=verify) if resp.status_code in self.http_to_zaqar: kwargs = {}