目录
- requests的SSL证书验证
- 1、对于HTTPS
- 2、以上步骤后,会出现警告
- requests处理不信任的ssl证书
- 不验证ssl证书
requests的SSL证书验证
1、对于HTTPS
默认情况下,启用SSL验证,如果无法验证SSL证书会导bnGiZQ致:
requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'cwww.cppcns.comertificate verify failed')],)",)
解决办法:
# 在requests中加入verify=False rwww.cppcns.comes = 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(InsecurebnGiZQRequestWarning)
requests处理不信任的ssl证书
不验证ssl证书
requests.get(url,verify=False)
以前bnGiZQ的12306证书不被认证
对于https协议
会有一个ssl证书的加密认证
以上为个人经验,希望能给大家一个参考,也希望大家多多支持我们。
精彩评论