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

时间:2015-08-31 22:00:15

标签: python python-2.7 openssl python-requests

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

此请求:

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))

生成此错误输出:

  

追踪(最近一次通话):     在run_code中输入文件“/home/mark/venvs/nessus/local/lib/python2.7/site-packages/IPython/core/interactiveshell.py”,第3035行       exec(code_obj,self.user_global_ns,self.user_ns)     文件“”,第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')     文件“/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/api.py”,第69行,获取       返回请求('get',url,params = params,** kwargs)     请求文件“/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/api.py”,第50行       response = session.request(method = method,url = url,** kwargs)     请求文件“/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/sessions.py”,第465行       resp = self.send(prep,** send_kwargs)     发送文件“/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/sessions.py”,第573行       r = adapter.send(request,** kwargs)     文件“/home/mark/venvs/nessus/local/lib/python2.7/site-packages/requests/adapters.py”,第431行,发送       提出SSLError(e,request = request)   SSLError:主机名'lsapi.seomoz.com'与'incapsula.com'不匹配,...

1 个答案:

答案 0 :(得分:0)

这个问题归结为与this one相同:您使用的Python版本不支持SNI。遵循this answer中的建议。