Ubuntu Python请求提取不正确的SSL证书

Ubuntu Python requests pulling incorrect SSL cert

Python中的请求包似乎引用了Ubuntu中不正确的SSL证书。 我正在使用请求2.6.2。 代码在Mac上运行良好但在Ubuntu上失败。 我感谢任何帮助!

这个请求:

1
2
3
query_string = https://lsapi.seomoz.com/linkscape/links/youtube.com?Sort=page_authority&Source=page_to_page&Filter=internal&LinkCols=4&Limit=50&Offset=0

requests.get(query_string, auth=(self.accessid,self.key))

产生此错误输出:

Traceback (most recent call last):
File"/home/mark/venvs/nessus/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 3035, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File"", line 1, in
requests.get('https://lsapi.seomoz.com/linkscape/links/youtube.com?Sort=page_authority&Source=page_to_page&Filter=internal&LinkCols=4&Limit=50&Offset=0')
File"/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/api.py", line 69, in get
return request('get', url, params=params, **kwargs)
File"/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/api.py", line 50, in request
response = session.request(method=method, url=url, **kwargs)
File"/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File"/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File"/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/adapters.py", line 431, in send
raise SSLError(e, request=request)
SSLError: hostname 'lsapi.seomoz.com' doesn't match either of 'incapsula.com', ...


这个问题归结为与此相同:您使用的Python版本不支持SNI。 按照这个答案中的建议。