I'm trying to suppress the below warning:
/usr/lib/python2.7/site-packages/urllib3/connection.py:251: SecurityWarning: Certificate has no `subjectAltName`, falling back to check for a `commonName` for now. This feature is being removed by major browsers and deprecated by RFC 2818. (See https://github.com/shazow/urllib3/issues/497 for details.)
SecurityWarning
my code is as follows
import requests
from orionsdk import SwisClient
#solarwinds creds
hostname = 'SolarWinds-Orion'
username = 'api'
password = 'XXXX'
v_path = '/var/www/itapp/tools/solarwinds.pem'
sites = SiteData.objects.exclude(site_type='Major Site').filter(is_live=True)
swis = SwisClient(hostname, username, password, verify=v_path)
query = """
SELECT NodeID
,NodeName
,IPAddress
FROM Orion.Nodes
WHERE NodeName LIKE '%NVR'
"""
requests.packages.urllib3.disable_warnings()
existing_results = swis.query(query)
nodes = existing_results["results"]
My searching shows that if I issue requests.packages.urllib3.disable_warnings(), then the warnings should be suppressed, but no matter where I put that line i always get the warning. Am I missing something or do i need to use something else?
Thanks
Hmm, if i am not mistaken requests uses its own vendored copy of urllib3 but the warning you are getting comes directly from your installed copy of urllib3.
Try doing:
import urllib3
urllib3.disable_warnings(urllib3.exceptions.SecurityWarning)
You can also handle any kind of warning generated by the warnings python library like this:
import warnings
warnings.simplefilter('ignore', urllib3.exceptions.SecurityWarning)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With