Python (Scripting) - Resolve InsecureRequestWarning
by
Jeremy Canfield |
Updated: October 11 2023
| Python (Scripting) articles
Let's say your Python script is returning an Insecure Request Warning, perhaps something like this.
/usr/local/lib/python3.6/site-packages/urllib3/connectionpool.py:1050: InsecureRequestWarning:
Unverified HTTPS request is being made to host 'foo.example.com'.
Adding certificate verification is strongly advised.
See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
InsecureRequestWarning
I typically happen upon this when using requests and verify=False to ignore SSL verification faults.
#!/usr/bin/python
import requests
requests.get("https://foo.example.com/api/vi/bar", verify=False)
And I'm usually able to disable the warnings like this.
#!/usr/bin/python
import requests
from requests.packages import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
requests.get("https://foo.example.com/api/vi/bar", verify=False)
Did you find this article helpful?
If so, consider buying me a coffee over at