From 2d7202ac819bc1e74473e104df2aa36c40d4d537 Mon Sep 17 00:00:00 2001 From: fredfortier Date: Tue, 14 Nov 2017 11:40:11 -0500 Subject: [PATCH] BUG: fixed issue #64 with SSL certificates --- catalyst/exchange/bittrex/bittrex_api.py | 6 ++++-- catalyst/exchange/poloniex/poloniex_api.py | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/catalyst/exchange/bittrex/bittrex_api.py b/catalyst/exchange/bittrex/bittrex_api.py index bc31607d..ca5f9c4a 100644 --- a/catalyst/exchange/bittrex/bittrex_api.py +++ b/catalyst/exchange/bittrex/bittrex_api.py @@ -3,11 +3,12 @@ import json import time import hmac import hashlib - +import ssl # Workaround for backwards compatibility # https://stackoverflow.com/questions/3745771/urllib-request-in-python-2-7 from six.moves import urllib + urlopen = urllib.request.urlopen @@ -48,7 +49,8 @@ class Bittrex_api(object): headers = {} req = urllib.request.Request(url, headers=headers) - response = json.loads(urlopen(req).read()) + response = json.loads(urlopen( + req, context=ssl._create_unverified_context()).read()) if response["result"]: return response["result"] diff --git a/catalyst/exchange/poloniex/poloniex_api.py b/catalyst/exchange/poloniex/poloniex_api.py index 8bf6bb83..894ba08b 100644 --- a/catalyst/exchange/poloniex/poloniex_api.py +++ b/catalyst/exchange/poloniex/poloniex_api.py @@ -3,6 +3,7 @@ import json import time import hmac import hashlib +import ssl from six.moves import urllib @@ -104,9 +105,10 @@ class Poloniex_api(object): req = urllib.request.Request( url, data=post_data, - headers=headers + headers=headers, ) - return json.loads(urlopen(req).read()) + return json.loads( + urlopen(req, context=ssl._create_unverified_context()).read()) def returnticker(self): return self.query('returnTicker', {})