关闭SSL证书验证

转载 Python3之关闭SSL证书验证

转载 Python requests 移除SSL认证,控制台输出InsecureRequestWarning取消方法

报错信息:

 1 Traceback (most recent call last):
 2   File "D:\Python36\lib\site-packages\urllib3\contrib\pyopenssl.py", line 441, in wrap_socket
 3     cnx.do_handshake()
 4   File "D:\Python36\lib\site-packages\OpenSSL\SSL.py", line 1806, in do_handshake
 5     self._raise_ssl_error(self._ssl, result)
 6   File "D:\Python36\lib\site-packages\OpenSSL\SSL.py", line 1546, in _raise_ssl_error
 7     _raise_current_error()
 8   File "D:\Python36\lib\site-packages\OpenSSL\_util.py", line 54, in exception_from_error_queue
 9     raise exception_type(errors)
10 OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')]
11 
12 During handling of the above exception, another exception occurred:

解决方法

1 #参数:verify=False
2 html = requests.get(item_url, headers=headers, verify=False)
3 # print(html.content)

今天遇到在requests设置移除SSL认证的时候,控制台会抛出以下警告:

1 C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py:843: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
2   InsecureRequestWarning)
3 C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py:843: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
4   InsecureRequestWarning)

解决方法

1 from requests.packages.urllib3.exceptions import InsecureRequestWarning
2 # 禁用安全请求警告
3 requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

 

转载于:https://www.cnblogs.com/littlebob/p/9262814.html

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值