I was experimenting with the VMware Web service SDK using pyVmomi and I got some error that need to be documented her. I’m using pyVmomi 6.0.0 in a vSphere 6 environment.
The first one was an SSL warning when using pyVmomi to acquire a service instance, if you try to use SmartConnect you will get the following ssl error:
I/O error(1): [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)
I forgot that I needed to secify an SSL context, this context describe the various SSL options. Her is how to use it:
import ssl .... # your other stuff context = ssl.SSLContext(ssl.PROTOCOL_TLSv1) context.verify_mode = ssl.CERT_NONE # Getting the Sevice Instance try: si = connect.SmartConnect(protocol="https",host=args.vc,port=443,user=args.user,pwd=args.pwd,sslContext=context) except IOError as e: print ("Could not connect to the vCenter instance error({}): {}".format(e.errno, e.strerror)) ....
How about the requests module in Python ?
If you are also trying to use this module with an untrusted SSL certificate, you will get the following error:
disable C:\Python35\lib\site-packages\requests\packages\urllib3\connectionpool.py:821: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html InsecureRequestWarning)
You have two choice her:
1- Disable All urllib3 warning like this
import urllib3 urllib3.disable_warnings() ...
Or
2 -Disable only this specific kind of error => InsecureRequestWarning:
from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) ....