klausf11
klausf11

Reputation: 95

Python 3.6 disable SSL (verify=False) does not work

iam using Python 3.6 on my Linux machine. And my HTTPS requests does not work.

import requests

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

The response is:

/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)

With the disable_warnings so that code:

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'))

I get this as response (u see in the picture) Error

Upvotes: 1

Views: 3435

Answers (1)

Maxime de Pachtere
Maxime de Pachtere

Reputation: 283

To disable this warning, you can use 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'))

Upvotes: 3

Related Questions