From f7b36a96e57809d521dfff13c232e45385da8ce9 Mon Sep 17 00:00:00 2001 From: Carles Garcia Cabot <carles.garcia.cabot@cern.ch> Date: Tue, 26 May 2020 12:14:22 +0200 Subject: [PATCH] Fix --capath option --- src/fts3/rest/client/request.py | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/fts3/rest/client/request.py b/src/fts3/rest/client/request.py index 8fbcf2d4..dcffeca7 100644 --- a/src/fts3/rest/client/request.py +++ b/src/fts3/rest/client/request.py @@ -26,12 +26,13 @@ import urllib3 class Request(object): - def __init__(self, ucert, ukey, capath=None, passwd=None, verify=False, access_token=None, connectTimeout=30, timeout=30): + def __init__(self, ucert, ukey, capath=None, passwd=None, verify=True, access_token=None, connectTimeout=30, timeout=30): self.ucert = ucert self.ukey = ukey self.passwd = passwd self.access_token = access_token self.verify = verify + self.capath = capath # Disable the warnings if not verify: urllib3.disable_warnings() @@ -93,11 +94,19 @@ class Request(object): from requests.auth import HTTPBasicAuth auth = HTTPBasicAuth(user, passw) - response = requests.request(method=method, url=str(url), - data=body, headers=_headers, verify=self.verify, - timeout=(self.connectTimeout, self.timeout), - cert=(self.ucert, self.ukey), - auth=auth) + if self.verify and self.capath: + self.verify = self.capath + + response = requests.request( + method=method, + url=str(url), + data=body, + headers=_headers, + verify=self.verify, + timeout=(self.connectTimeout, self.timeout), + cert=(self.ucert, self.ukey), + auth=auth, + ) #log.debug(response.text) -- GitLab