add the ability to disable cert verification

This commit is contained in:
Damien Elmes 2017-12-07 17:15:20 +10:00
parent 39c0a57b13
commit 774c19e83e
2 changed files with 6 additions and 4 deletions

View file

@ -459,6 +459,8 @@ class LocalServer(Syncer):
class AnkiRequestsClient: class AnkiRequestsClient:
verify = True
def __init__(self): def __init__(self):
self.session = requests.Session() self.session = requests.Session()
@ -466,13 +468,13 @@ class AnkiRequestsClient:
data = _MonitoringFile(data) data = _MonitoringFile(data)
headers['User-Agent'] = self._agentName() headers['User-Agent'] = self._agentName()
return self.session.post( return self.session.post(
url, data=data, headers=headers, stream=True, timeout=60) url, data=data, headers=headers, stream=True, timeout=60, verify=self.verify)
def get(self, url, headers=None): def get(self, url, headers=None):
if headers is None: if headers is None:
headers = {} headers = {}
headers['User-Agent'] = self._agentName() headers['User-Agent'] = self._agentName()
return self.session.get(url, stream=True, timeout=60) return self.session.get(url, stream=True, timeout=60, verify=self.verify)
def streamContent(self, resp): def streamContent(self, resp):
resp.raise_for_status() resp.raise_for_status()

View file

@ -188,9 +188,9 @@ AnkiWeb is too busy at the moment. Please try again in a few minutes.""")
elif "code: 413" in err: elif "code: 413" in err:
return _("Your collection or a media file is too large to sync.") return _("Your collection or a media file is too large to sync.")
elif "EOF occurred in violation of protocol" in err: elif "EOF occurred in violation of protocol" in err:
return _("Error establishing a secure connection. This is usually caused by antivirus, firewall or VPN software, or problems with your ISP.") return _("Error establishing a secure connection. This is usually caused by antivirus, firewall or VPN software, or problems with your ISP.") + " (eof)"
elif "certificate verify failed" in err: elif "certificate verify failed" in err:
return _("Error establishing a secure connection. This is usually caused by antivirus, firewall or VPN software, or problems with your ISP.") return _("Error establishing a secure connection. This is usually caused by antivirus, firewall or VPN software, or problems with your ISP.") + " (invalid cert)"
return err return err
def _getUserPass(self): def _getUserPass(self):