Bootstrap FreeKB - Python (Scripting) - Resolve InsecureRequestWarning
Python (Scripting) - Resolve InsecureRequestWarning

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter a5a390 in the box below so that we can be sure you are a human.