SSL3_GET_SERVER_CERTIFICATE 错误解决办法
requests模块之前一直正常的,某一天开始对https的请求都抛错误了:
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
完整的:
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html# insecureplatformwarning. InsecurePlatformWarningTraceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 68, in get return request('get', url, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/api.py", line 50, in request response = session.request(method=method, url=url, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 464, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/sessions.py", line 576, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python2.7/dist-packages/requests/adapters.py", line 431, in send raise SSLError(e, request=request)requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
试过:
sudo apt-get install ca-certificates
sudo update-ca-certificates
没效果,
最后试了下面的起效的:
sudo pip uninstall -y certifi
sudo pip install certifi==2015.04.28
当然,还是有警告:
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html# insecureplatformwarning. InsecurePlatformWarning
不够,至少可以先用着了。原因估计就是高版本(2016.2.8)的certifi对证书验证更为严格了。
关键字:Python, SSL, request
版权声明
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处。如若内容有涉嫌抄袭侵权/违法违规/事实不符,请点击 举报 进行投诉反馈!