2016-03-31

python : disabling SSL verification on pyvmomi on python


  • self signed certificate ? 
  • RHEL6 ? python 2.6 and 2.7.10 mixed environment ?
  • pyvmomi 5.5+ ?

Looking for a quick fix ?
...
File "/usr/lib/python2.6/site-packages/requests/adapters.py", line 447, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 1] _ssl.c:492: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

[root@fb7a3cd8c69d ~]# vim my_script.pyt
...
    context = None
    try:
        # Disabling SSL certificate verification       
        context = ssl.SSLContext(ssl.PROTOCOL_SSLv3)
        context.verify_mode = ssl.CERT_NONE
    except AttributeError:
        rget = requests.get
        requests.get = lambda obj, *args,**kwargs: rget(obj,verify=False)
        requests.packages.urllib3.disable_warnings()

    si = SmartConnect(host=args.host,
            user=user,
            pwd=args.password,
            port=int(args.port), sslContext=context)


And you are good to go. This will resolve the issue, and allow you to focus on your life

PS: You would still need to fix this to use basic auth.

No comments:

Post a Comment

GitLab runner on Windows with bash shell on windows contianer on Docker

As part of your pipeline, you may need to perform browser testing across different platforms/environments. To minimize testing time, it'...