概述
2019独角兽企业重金招聘Python工程师标准>>>
如题访问部分私有SSL证书网站时报如下错误
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
测试环境
kali linux 1.1.0
Python 2.7.8
python-openssl 0.13-2+deb7u1
requests 2.3.0
测试代码
#/usr/bin/python
#coding=utf-8
import requests
def getHtml():
#自定义的证书需要指定自动忽略对SSL证书的验证
req = requests.get('https://hg.mornie.org',verify=False)
print req.text
if __name__ == '__main__':
getHtml()
如上测试会报错误如下
Traceback (most recent call last):
File "/root/Desktop/erp.py", line 32, in <module>
getHtml()
File "/root/Desktop/erp.py", line 25, in getHtml
req = requests.get('https://hg.mornie.org',verify=True)
File "/usr/local/lib/python2.7/dist-packages/requests-2.3.0-py2.7.egg/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.3.0-py2.7.egg/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.3.0-py2.7.egg/requests/sessions.py", line 456, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.3.0-py2.7.egg/requests/sessions.py", line 559, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/requests-2.3.0-py2.7.egg/requests/adapters.py", line 382, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
在国外搜索了半天资料后,发现是最近官方出现的一个bug,现已修复,可更新
在更新python-openssl包到0.14-1~kali1后成功解决问题(或者更新到最新版本)
转载于:https://my.oschina.net/u/1188877/blog/380894
最后
以上就是专一心锁为你收集整理的解决python的requests模块访问私有SSL证书产生的报错问题的全部内容,希望文章能够帮你解决解决python的requests模块访问私有SSL证书产生的报错问题所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复