From 8826f8eb81f38af2fbbd60a71695c382d4807001 Mon Sep 17 00:00:00 2001 From: hochm Date: Mon, 17 Jun 2019 13:14:12 +0200 Subject: [PATCH] Compatibility with python 3.7 Adding certifi as cafile, to ensure compatibility with SSL/Python 3.7 cert handling. --- graphqlclient/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/graphqlclient/client.py b/graphqlclient/client.py index b25de54..b725005 100644 --- a/graphqlclient/client.py +++ b/graphqlclient/client.py @@ -1,4 +1,6 @@ from six.moves import urllib +import certifi +import ssl import json class GraphQLClient: @@ -26,7 +28,8 @@ def _send(self, query, variables): req = urllib.request.Request(self.endpoint, json.dumps(data).encode('utf-8'), headers) try: - response = urllib.request.urlopen(req) + context = ssl.create_default_context(cafile=certifi.where()) + response = urllib.request.urlopen(req, context=context) return response.read().decode('utf-8') except urllib.error.HTTPError as e: print((e.read()))