01-23-2019 07:38 AM - edited 03-01-2019 05:45 AM
I am trying to use the python code located here . I am running into the following error when I do this. Does anybody know how to disable this error?
/usr/local/lib/python2.7/site-packages/urllib3-1.22-py2.7.egg/urllib3/connectionpool.py:858: 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)
01-23-2019 08:01 AM
Hi there,
Try adding this to your code:
import requests requests.packages.urllib3.disable_warnings()
cheers,
Seb.
01-23-2019 08:18 AM
...or if that doesn't work filter it via the CLI:
python -Wignore::InsecureRequestWarning your_script.py
01-23-2019 08:26 AM
Both of those solutions work for this code, however when I try and use this code I get the following error.
Traceback (most recent call last):
File "Development/python-old/ACI/auth.py", line 14, in <module>
ret = requests.get(url)
File "/usr/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/sessions.py", line 508, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/sessions.py", line 618, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/requests-2.18.4-py2.7.egg/requests/adapters.py", line 506, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='192.168.1.1, port=443): Max retries exceeded with url: /api/node/class/procEntity.xml (Caused by SSLError(SSLError(1, u'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)'),))
01-23-2019 08:49 AM
I'm not able to view you pastebi source ode for some reason...
anyhow you should be able to side step this error by telling requests not to verify the SSL Cert being offered by 192.168.1.1, by adding the parameter verify=False
Something like:
response = session.send(request_pr, verify=False)
cheers,
Seb.
01-23-2019 09:04 AM
Here is the code that was added in. It was added between moDir.login() and moDir.logout()
01-23-2019 12:12 PM
OK make this change:
ret = requests.get(url, verify=False)
In case you are interested take a look at:
https://github.com/requests/requests/blob/master/requests/sessions.py
...starting a line 466. The parameter we are interested in states:
:param verify: (optional) Either a boolean, in which case it controls whether we verify the server's TLS certificate, or a string, in which case it must be a path to a CA bundle to use. Defaults to ``True``.
cheers,
Seb.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide