diff --git a/open_facebook/api.py b/open_facebook/api.py index fdb88716..b3a121a2 100644 --- a/open_facebook/api.py +++ b/open_facebook/api.py @@ -97,10 +97,10 @@ try: # python 2 imports from urlparse import urlparse - from urllib2 import build_opener, HTTPError, URLError + from urllib2 import build_opener, HTTPError, URLError, HTTPSHandler except ImportError: # python 3 imports - from urllib.error import HTTPError, URLError + from urllib.error import HTTPError, URLError, HTTPSHandler from urllib.parse import urlparse from urllib.request import build_opener @@ -164,7 +164,10 @@ def _request(cls, url, post_data=None, timeout=REQUEST_TIMEOUT, return response # nicely identify ourselves before sending the request - opener = build_opener() + ctx = ssl.create_default_context() + ctx.check_hostname = False + ctx.verify_mode = ssl.CERT_NONE + opener = build_opener(HTTPSHandler(context=ctx)) opener.addheaders = [('User-agent', 'Open Facebook Python')] # get the statsd path to track response times with