I am writing scripts in Python2.6 with use of pyVmomi and while using one of the connection methods:
service_instance = connect.SmartConnect(host=args.ip,
Why not using pyvmomi original function SmartConnectNoSSL
.
They added this function on June 14, 2016
and named it ConnectNoSSL
, one day after they changed the name to SmartConnectNoSSL
, use that instead of by passing the warning with unnecessary lines of code in your project?
Provides a standard method for connecting to a specified server without SSL verification. Useful when connecting to servers with self-signed certificates or when you wish to ignore SSL altogether
service_instance = connect.SmartConnectNoSSL(host=args.ip,
user=args.user,
pwd=args.password)
This is the answer in 2017. urllib3
not a part of requests
anymore
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
The accepted answer doesn't work if some package vendors it's own copy of urllib3, in which case this will still work:
import warnings
warnings.filterwarnings('ignore', message='Unverified HTTPS request')