gpt4 book ai didi

Python 3.6 禁用 SSL (verify=False) 不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 13:35:04 26 4
gpt4 key购买 nike

我在我的 Linux 机器上使用 Python 3.6。而且我的 HTTPS 请求不起作用。

import requests

requests.get('https://192.168.56.101:4665/v1/objects/services/docker-icinga2!random-005', verify=False, auth=('root', 'icinga'))

响应是:

/usr/local/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py:852: 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)

随着 disable_warnings所以代码:

import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning

# Disable flag warning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

requests.get('https://192.168.56.101:4665/v1/objects/services/docker-
icinga2!random-005', auth=('root', 'icinga'))

我得到这个作为回应(你在图片中看到) Error

最佳答案

要禁用此警告,您可以使用 requests.package.disable_warnings

from requests.packages.urllib3.exceptions import InsecureRequestWarning

# Disable flag warning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)

requests.get('https://192.168.56.101:4665/v1/objects/services/docker-icinga2!random-005', verify=False, auth=('root', 'icinga'))

关于Python 3.6 禁用 SSL (verify=False) 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42714416/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com