Python requests的SSL证书验证方式
作者:_Miya 时间:2021-10-06 09:21:51
requests的SSL证书验证
1、对于HTTPS
默认情况下,启用SSL验证,如果无法验证SSL证书会导致:
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",)
解决办法:
# 在requests中加入verify=False
res = requests.get(ur,verify=False)
2、以上步骤后,会出现警告
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 InsecureRequestWarning)
解决办法:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
# 禁用安全请求警告
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
requests处理不信任的ssl证书
不验证ssl证书
requests.get(url,verify=False)
以前的12306证书不被认证
对于https协议
会有一个ssl证书的加密认证
来源:https://blog.csdn.net/xiaowo_/article/details/103857131
标签:Python,requests,SSL证书
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Python中如何创建多线程?
2022-11-25 15:52:34
python-itchat 获取微信群用户信息的实例
2022-11-09 18:15:41
Mootools 1.2教程(5)——事件处理
2008-11-19 16:33:00
使用Numpy读取CSV文件,并进行行列删除的操作方法
2023-05-05 03:26:11
Python中私有属性的定义方式
2023-11-01 16:47:17
php指定长度分割字符串str_split函数用法示例
2023-07-08 23:25:51
实例分析python3实现并发访问水平切分表
2023-12-29 06:43:45
python实现马耳可夫链算法实例分析
2022-08-13 00:27:08
Python通过len函数返回对象长度
2023-05-05 06:04:12
对Django的restful用法详解(自带的增删改查)
2023-11-12 07:45:04
![](https://img.aspxhome.com/file/2023/8/110228_0s.jpg)
PHP获取类私有属性的3种方法
2023-11-20 10:32:16
![](https://img.aspxhome.com/file/2023/6/106296_0s.jpg)
利用Python求阴影部分的面积实例代码
2021-10-05 15:18:03
![](https://img.aspxhome.com/file/2023/3/89103_0s.png)
python神经网络学习利用PyTorch进行回归运算
2023-02-24 13:30:47
Python使用pygame模块编写俄罗斯方块游戏的代码实例
2021-11-15 02:29:29
![](https://img.aspxhome.com/file/2023/3/69533_0s.png)
python2.7+selenium2实现淘宝滑块自动认证功能
2023-06-06 14:29:34
![](https://img.aspxhome.com/file/2023/7/115667_0s.png)
Python中对象迭代与反迭代的技巧总结
2023-06-08 04:25:33
间歇向上无缝翻滚代码
2008-05-05 12:30:00
Python中使用PDB库调试程序
2022-02-24 11:25:49
python 如何将数据写入本地txt文本文件的实现方法
2021-05-02 14:11:52
Django框架 Pagination分页实现代码实例
2021-08-18 19:32:52