nsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is st

时间:2023-02-20 17:00:06


一、场景

本人利用python的requtsts发送请求,请求的内网链接如 ​​https://192.168.131.128/user​​,出现如下错误

InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised.
See: InsecureRequestWarning)

二、出现原因

在未启用证书验证的情况下向 HTTPS URL 发出请求时会发生这种情况。按照证书验证 指南解决此警告。

三、解决办法

  • ​希望禁用警告,则可以使用disable_warnings()​​:
import urllib3
urllib3.disable_warnings()
  • ​使用标准logging模块捕获警告​
logging.captureWarnings(True)