Certificate verify traceback when trying to connect to vcenter using SmartConnect() on Mac OS X Yosemite with python 2.7 #235

Closed
nmadhok opened this Issue Apr 7, 2015 · 35 comments

Comments

Projects
None yet
@nmadhok
Contributor

nmadhok commented Apr 7, 2015

Getting a traceback when trying to connect to vcenter using SmartConnect() on Mac OS X Yosemite using python 2.7.

Nitins-MacBook-Pro: root# python
Python 2.7.9 (default, Feb 10 2015, 03:28:08) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyVim import connect
>>> si = connect.SmartConnect(host='myvcenter.domain.com', user='username', pwd='verybadpass')
/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
  InsecureRequestWarning)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 590, in SmartConnect
    path=path)
  File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 234, in Connect
    keyFile, certFile)
  File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 319, in __Login
    reraise(vim.fault.HostConnectFault, fault, traceback)
  File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 307, in __Login
    content = si.RetrieveContent()
  File "/usr/local/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 566, in <lambda>
    self.f(*(self.args + (obj,) + args), **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 375, in _InvokeMethod
    return self._stub.InvokeMethod(self, info, args)
  File "/usr/local/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py", line 1254, in InvokeMethod
    conn.request('POST', self.path, req, headers)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1001, in request
    self._send_request(method, url, body, headers)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1035, in _send_request
    self.endheaders(body)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 850, in _send_output
    self.send(msg)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 812, in send
    self.connect()
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1212, in connect
    server_hostname=server_hostname)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 350, in wrap_socket
    _context=self)
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 566, in __init__
    self.do_handshake()
  File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 788, in do_handshake
    self._sslobj.do_handshake()
pyVmomi.VmomiSupport.HostConnectFault: (vim.fault.HostConnectFault) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   msg = '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)',
   faultCause = <unset>,
   faultMessage = (vmodl.LocalizableMessage) []
}
>>> 
Nitins-MacBook-Pro: root# uname -a
Darwin Nitins-MacBook-Pro.local 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64
Nitins-MacBook-Pro: root# pip show pyvmomi

---
Metadata-Version: 1.1
Name: pyvmomi
Version: 5.5.0.2014.1.1
Summary: VMware vSphere Python SDK
Home-page: https://github.com/vmware/pyvmomi
Author: VMware, Inc.
Author-email: jhu@vmware.com
License: License :: OSI Approved :: Apache Software License
Location: /usr/local/lib/python2.7/site-packages
Requires: requests, six
Nitins-MacBook-Pro: root# pip show requests

---
Metadata-Version: 2.0
Name: requests
Version: 2.6.0
Summary: Python HTTP for Humans.
Home-page: http://python-requests.org
Author: Kenneth Reitz
Author-email: me@kennethreitz.com
License: Apache 2.0
Location: /usr/local/lib/python2.7/site-packages
Requires: 
Nitins-MacBook-Pro: root# pip show six

---
Metadata-Version: 1.1
Name: six
Version: 1.9.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /usr/local/lib/python2.7/site-packages/six-1.9.0-py2.7.egg
Requires: 

@nmadhok nmadhok changed the title from Certificate verify traceback when trying to connect to vcenter using SmartConnect() on Mac to Certificate verify traceback when trying to connect to vcenter using SmartConnect() on Mac OS X Yosemite Apr 7, 2015

@nmadhok nmadhok changed the title from Certificate verify traceback when trying to connect to vcenter using SmartConnect() on Mac OS X Yosemite to Certificate verify traceback when trying to connect to vcenter using SmartConnect() on Mac OS X Yosemite with python 2.7 Apr 7, 2015

@michaelrice

This comment has been minimized.

Show comment
Hide comment
@michaelrice

michaelrice Apr 7, 2015

Contributor

Isn't that a duplicate of this: #212
?
On Apr 7, 2015 6:15 AM, "Nitin Madhok" notifications@github.com wrote:

Getting a traceback when trying to connect to vcenter using SmartConnect()
from Mac.

Nitins-MacBook-Pro: root# python
Python 2.7.9 (default, Feb 10 2015, 03:28:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

from pyVim import connect
si = connect.SmartConnect(host='myvcenter.domain.com', user='username', pwd='verybadpass')
/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 590, in SmartConnect
path=path)
File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 234, in Connect
keyFile, certFile)
File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 319, in *Login
reraise(vim.fault.HostConnectFault, fault, traceback)
File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 307, in __Login
content = si.RetrieveContent()
File "/usr/local/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 566, in
self.f(_(self.args + (obj,) + args), _kwargs)
File "/usr/local/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 375, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "/usr/local/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py", line 1254, in InvokeMethod
conn.request('POST', self.path, req, headers)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1001, in request
self._send_request(method, url, body, headers)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1035, in _send_request
self.endheaders(body)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 997, in endheaders
self._send_output(message_body)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 850, in _send_output
self.send(msg)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 812, in send
self.connect()
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1212, in connect
server_hostname=server_hostname)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 350, in wrap_socket
_context=self)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 566, in __init

self.do_handshake()
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 788, in do_handshake
self._sslobj.do_handshake()
pyVmomi.VmomiSupport.HostConnectFault: (vim.fault.HostConnectFault) {
dynamicType = ,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)',
faultCause = ,
faultMessage = (vmodl.LocalizableMessage) []
}

Nitins-MacBook-Pro: root# uname -a
Darwin Nitins-MacBook-Pro.local 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64

Nitins-MacBook-Pro: root# pip show pyvmomi

Metadata-Version: 1.1
Name: pyvmomi
Version: 5.5.0.2014.1.1
Summary: VMware vSphere Python SDK
Home-page: https://github.com/vmware/pyvmomi
Author: VMware, Inc.
Author-email: jhu@vmware.com
License: License :: OSI Approved :: Apache Software License
Location: /usr/local/lib/python2.7/site-packages
Requires: requests, six

Nitins-MacBook-Pro: root# pip show requests

Metadata-Version: 2.0
Name: requests
Version: 2.6.0
Summary: Python HTTP for Humans.
Home-page: http://python-requests.org
Author: Kenneth Reitz
Author-email: me@kennethreitz.com
License: Apache 2.0
Location: /usr/local/lib/python2.7/site-packages
Requires:

Nitins-MacBook-Prok: root# pip show six

Metadata-Version: 1.1
Name: six
Version: 1.9.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /usr/local/lib/python2.7/site-packages/six-1.9.0-py2.7.egg
Requires:


Reply to this email directly or view it on GitHub
#235.

Contributor

michaelrice commented Apr 7, 2015

Isn't that a duplicate of this: #212
?
On Apr 7, 2015 6:15 AM, "Nitin Madhok" notifications@github.com wrote:

Getting a traceback when trying to connect to vcenter using SmartConnect()
from Mac.

Nitins-MacBook-Pro: root# python
Python 2.7.9 (default, Feb 10 2015, 03:28:08)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

from pyVim import connect
si = connect.SmartConnect(host='myvcenter.domain.com', user='username', pwd='verybadpass')
/usr/local/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:769: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 590, in SmartConnect
path=path)
File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 234, in Connect
keyFile, certFile)
File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 319, in *Login
reraise(vim.fault.HostConnectFault, fault, traceback)
File "/usr/local/lib/python2.7/site-packages/pyVim/connect.py", line 307, in __Login
content = si.RetrieveContent()
File "/usr/local/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 566, in
self.f(_(self.args + (obj,) + args), _kwargs)
File "/usr/local/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 375, in _InvokeMethod
return self._stub.InvokeMethod(self, info, args)
File "/usr/local/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py", line 1254, in InvokeMethod
conn.request('POST', self.path, req, headers)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1001, in request
self._send_request(method, url, body, headers)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1035, in _send_request
self.endheaders(body)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 997, in endheaders
self._send_output(message_body)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 850, in _send_output
self.send(msg)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 812, in send
self.connect()
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1212, in connect
server_hostname=server_hostname)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 350, in wrap_socket
_context=self)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 566, in __init

self.do_handshake()
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 788, in do_handshake
self._sslobj.do_handshake()
pyVmomi.VmomiSupport.HostConnectFault: (vim.fault.HostConnectFault) {
dynamicType = ,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)',
faultCause = ,
faultMessage = (vmodl.LocalizableMessage) []
}

Nitins-MacBook-Pro: root# uname -a
Darwin Nitins-MacBook-Pro.local 14.1.0 Darwin Kernel Version 14.1.0: Thu Feb 26 19:26:47 PST 2015; root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64

Nitins-MacBook-Pro: root# pip show pyvmomi

Metadata-Version: 1.1
Name: pyvmomi
Version: 5.5.0.2014.1.1
Summary: VMware vSphere Python SDK
Home-page: https://github.com/vmware/pyvmomi
Author: VMware, Inc.
Author-email: jhu@vmware.com
License: License :: OSI Approved :: Apache Software License
Location: /usr/local/lib/python2.7/site-packages
Requires: requests, six

Nitins-MacBook-Pro: root# pip show requests

Metadata-Version: 2.0
Name: requests
Version: 2.6.0
Summary: Python HTTP for Humans.
Home-page: http://python-requests.org
Author: Kenneth Reitz
Author-email: me@kennethreitz.com
License: Apache 2.0
Location: /usr/local/lib/python2.7/site-packages
Requires:

Nitins-MacBook-Prok: root# pip show six

Metadata-Version: 1.1
Name: six
Version: 1.9.0
Summary: Python 2 and 3 compatibility utilities
Home-page: http://pypi.python.org/pypi/six/
Author: Benjamin Peterson
Author-email: benjamin@python.org
License: MIT
Location: /usr/local/lib/python2.7/site-packages/six-1.9.0-py2.7.egg
Requires:


Reply to this email directly or view it on GitHub
#235.

@nmadhok

This comment has been minimized.

Show comment
Hide comment
@nmadhok

nmadhok Apr 7, 2015

Contributor

@michaelrice Not sure if you would call this a duplicate. This is more an issue and less of an enhancement. It shows the traceback and quits without connecting. Also, this issue has information that #212 doesn't have.

Contributor

nmadhok commented Apr 7, 2015

@michaelrice Not sure if you would call this a duplicate. This is more an issue and less of an enhancement. It shows the traceback and quits without connecting. Also, this issue has information that #212 doesn't have.

@rreubenur

This comment has been minimized.

Show comment
Hide comment
@rreubenur

rreubenur Apr 7, 2015

@nmadhok do yo have https_proxy enabled ?

@nmadhok do yo have https_proxy enabled ?

@nmadhok

This comment has been minimized.

Show comment
Hide comment
@nmadhok

nmadhok Apr 10, 2015

Contributor

@rreubenur Not sure. Quick way to check that?

Contributor

nmadhok commented Apr 10, 2015

@rreubenur Not sure. Quick way to check that?

@jm66

This comment has been minimized.

Show comment
Hide comment
@jm66

jm66 Apr 14, 2015

Same issue here.

Python 2.7.9
---
Metadata-Version: 1.1
Name: pyvmomi
Version: 5.5.0-DEVELOPMENT
Summary: VMware vSphere Python SDK
Home-page: https://github.com/vmware/pyvmomi
Author: VMware, Inc.
Author-email: jhu@vmware.com
License: License :: OSI Approved :: Apache Software License
Location: /usr/local/lib/python2.7/site-packages/pyvmomi-5.5.0_DEVELOPMENT-py2.7.egg
Requires: requests, six
---
Darwin hostname 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

jm66 commented Apr 14, 2015

Same issue here.

Python 2.7.9
---
Metadata-Version: 1.1
Name: pyvmomi
Version: 5.5.0-DEVELOPMENT
Summary: VMware vSphere Python SDK
Home-page: https://github.com/vmware/pyvmomi
Author: VMware, Inc.
Author-email: jhu@vmware.com
License: License :: OSI Approved :: Apache Software License
Location: /usr/local/lib/python2.7/site-packages/pyvmomi-5.5.0_DEVELOPMENT-py2.7.egg
Requires: requests, six
---
Darwin hostname 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

@hartsock

This comment has been minimized.

Show comment
Hide comment
@hartsock

hartsock Apr 14, 2015

Member

Okay, this is going to have to be one of the first things I work on as soon as I can circle back to pyVmomi work.

Member

hartsock commented Apr 14, 2015

Okay, this is going to have to be one of the first things I work on as soon as I can circle back to pyVmomi work.

@hartsock hartsock self-assigned this Apr 14, 2015

@hartsock hartsock added this to the pyVmomi 2015.1 milestone Apr 14, 2015

@hartsock hartsock added the blocker label Apr 14, 2015

@nmadhok

This comment has been minimized.

Show comment
Hide comment
@nmadhok

nmadhok Apr 14, 2015

Contributor

@hartsock Thanks!

Contributor

nmadhok commented Apr 14, 2015

@hartsock Thanks!

@lrhazi

This comment has been minimized.

Show comment
Hide comment
@lrhazi

lrhazi May 17, 2015

is there a work around for this? can one disable cert verify from user script?
or can one do something to make cert verification succeed?

lrhazi commented May 17, 2015

is there a work around for this? can one disable cert verify from user script?
or can one do something to make cert verification succeed?

@nmadhok

This comment has been minimized.

Show comment
Hide comment
@nmadhok

nmadhok May 17, 2015

Contributor

@lrhazi

Here's the workaround:

try:
    si = SmartConnect(
        host=url,
        user=username,
        pwd=password,
    )
except Exception as exc:
    if isinstance(exc, vim.fault.HostConnectFault) and '[SSL: CERTIFICATE_VERIFY_FAILED]' in exc.msg:
        try:
            import ssl
            default_context = ssl._create_default_https_context
            ssl._create_default_https_context = ssl._create_unverified_context
            si = SmartConnect(
                host=url,
                user=username,
                pwd=password,
            )
            ssl._create_default_https_context = default_context
        except Exception as exc1:
            raise Exception(exc1)
    else:
        raise Exception(exc)
Contributor

nmadhok commented May 17, 2015

@lrhazi

Here's the workaround:

try:
    si = SmartConnect(
        host=url,
        user=username,
        pwd=password,
    )
except Exception as exc:
    if isinstance(exc, vim.fault.HostConnectFault) and '[SSL: CERTIFICATE_VERIFY_FAILED]' in exc.msg:
        try:
            import ssl
            default_context = ssl._create_default_https_context
            ssl._create_default_https_context = ssl._create_unverified_context
            si = SmartConnect(
                host=url,
                user=username,
                pwd=password,
            )
            ssl._create_default_https_context = default_context
        except Exception as exc1:
            raise Exception(exc1)
    else:
        raise Exception(exc)
@michaelrice

This comment has been minimized.

Show comment
Hide comment
@michaelrice

michaelrice May 17, 2015

Contributor

I think the subject of this report should be changed to drop the OSX bits, it might help describe this more generally. This is not specific to OSX in any way because it is being caused by the change to python 2.7.9 which was pointed out in #212. #212 probably shouldn't be labeled as an enhancement. Because of this change to 2.7.9 it really makes it feel more like a bug (one I still think should be a python bug but the python devs do not agree). As it is now the current release of pyVmomi is "broken" on 2.7.9 and even on some 2.7.8 releases where they back ported the ssl patch (Ive read AWS did this in a gevent bug report about the same issue) instead of rolling a new 2.7.9 release out.

I posted a work around to the mailing list a couple weeks ago which is a less elegant way of doing what @nmadhok is doing. It has also been added to py-vpoller as well.

@hartsock I think we need to get a suitable patch made for connect.py and get quick release out to address this problem so that pyVmomi doesnt seem "broken" to 2.7.9 users.

Contributor

michaelrice commented May 17, 2015

I think the subject of this report should be changed to drop the OSX bits, it might help describe this more generally. This is not specific to OSX in any way because it is being caused by the change to python 2.7.9 which was pointed out in #212. #212 probably shouldn't be labeled as an enhancement. Because of this change to 2.7.9 it really makes it feel more like a bug (one I still think should be a python bug but the python devs do not agree). As it is now the current release of pyVmomi is "broken" on 2.7.9 and even on some 2.7.8 releases where they back ported the ssl patch (Ive read AWS did this in a gevent bug report about the same issue) instead of rolling a new 2.7.9 release out.

I posted a work around to the mailing list a couple weeks ago which is a less elegant way of doing what @nmadhok is doing. It has also been added to py-vpoller as well.

@hartsock I think we need to get a suitable patch made for connect.py and get quick release out to address this problem so that pyVmomi doesnt seem "broken" to 2.7.9 users.

@hartsock

This comment has been minimized.

Show comment
Hide comment
@hartsock

hartsock May 27, 2015

Member

@michaelrice agreed. This will have to take priority over some of my other work.

Member

hartsock commented May 27, 2015

@michaelrice agreed. This will have to take priority over some of my other work.

hartsock added a commit to hartsock/pyvmomi that referenced this issue May 29, 2015

optionally allow unverified certificates
Toggles on and off strict host name verification in the standard python SSL
library. A change was introduced to Python's SSL verification behavior with
[PEP 0466](https://www.python.org/dev/peps/pep-0466/) which forces this
library to consider a set of changes to preserve backward compatability.

The intention of PEP 0466 is to improve SSL security for Python programmers
but this changes default behaviors. This change proposes keeping the default
behaviors undisturbed but forcing users and developers working in insecure
environments to become aware of the change and adjust their security measures
and code accordingly.

fixes: #212, #235, and #179

hartsock added a commit to hartsock/pyvmomi that referenced this issue May 29, 2015

optionally allow unverified certificates
Toggles on and off strict host name verification in the standard python SSL
library. A change was introduced to Python's SSL verification behavior with
[PEP 0466](https://www.python.org/dev/peps/pep-0466/) which forces this
library to consider a set of changes to preserve backward compatability.

The intention of PEP 0466 is to improve SSL security for Python programmers
but this changes default behaviors. This change proposes keeping the default
behaviors undisturbed but forcing users and developers working in insecure
environments to become aware of the change and adjust their security measures
and code accordingly.

fixes: #212, #235, and #179
@flaub

This comment has been minimized.

Show comment
Hide comment
@flaub

flaub Nov 6, 2015

Any news on this?

flaub commented Nov 6, 2015

Any news on this?

@mdcsaenz

This comment has been minimized.

Show comment
Hide comment
@mdcsaenz

mdcsaenz Dec 4, 2015

I have the same issue except I am in python 2.7.3 and I can not use _create_default_https_context since ssl package does not have that attribute. and upgrading at this point is not an option? Any other option?
ERROR:root:'module' object has no attribute '_create_default_https_context'

mdcsaenz commented Dec 4, 2015

I have the same issue except I am in python 2.7.3 and I can not use _create_default_https_context since ssl package does not have that attribute. and upgrading at this point is not an option? Any other option?
ERROR:root:'module' object has no attribute '_create_default_https_context'

@spicyramen

This comment has been minimized.

Show comment
Hide comment
@spicyramen

spicyramen Dec 5, 2015

I modified Line 339 "verify" variable to to False in /usr/local/lib/python2.7/dist-packages/requests/adapters.py
self.cert_verify(conn, request.url, False, cert)

I modified Line 339 "verify" variable to to False in /usr/local/lib/python2.7/dist-packages/requests/adapters.py
self.cert_verify(conn, request.url, False, cert)

@mdcsaenz

This comment has been minimized.

Show comment
Hide comment
@mdcsaenz

mdcsaenz Dec 7, 2015

@spicyramen that worked! Thank you, I created a patch on my end to add to my bootstrap file.

mdcsaenz commented Dec 7, 2015

@spicyramen that worked! Thank you, I created a patch on my end to add to my bootstrap file.

@michaelrice

This comment has been minimized.

Show comment
Hide comment
@michaelrice

michaelrice Dec 7, 2015

Contributor

that is such a bad thing to do. I hope that anyone who follows that knows what ramifications it has, or even better just does not follow that advice

Contributor

michaelrice commented Dec 7, 2015

that is such a bad thing to do. I hope that anyone who follows that knows what ramifications it has, or even better just does not follow that advice

@gorantornqvist

This comment has been minimized.

Show comment
Hide comment
@gorantornqvist

gorantornqvist Dec 9, 2015

This was the only workaround that worked for me ...

try:
        import ssl
        context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
        context.verify_mode = ssl.CERT_NONE
        service_instance = connect.SmartConnect(host=args.host,
                                                user=args.user,
                                                pwd=args.password,
                                                port=int(args.port),
                                                sslContext=context)

This was the only workaround that worked for me ...

try:
        import ssl
        context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
        context.verify_mode = ssl.CERT_NONE
        service_instance = connect.SmartConnect(host=args.host,
                                                user=args.user,
                                                pwd=args.password,
                                                port=int(args.port),
                                                sslContext=context)
@lmcdasm

This comment has been minimized.

Show comment
Hide comment
@lmcdasm

lmcdasm Dec 21, 2015

Hey Gorantornqvist's method of creating a context and then assigning it worked for me in py and py3.

here is the hello world with yaml sample with it working.
4 import ssl
71 def main():
72 """
73 Simple command-line program for listing the virtual machines on a system.
74 """
75
76 args = get_args()
77
78 try:
79 my_vcr = vcr.VCR()
80 # use the vcr instance to setup an instance of service_instance
81 with my_vcr.use_cassette('hello_world_vcenter.yaml',
82 record_mode='all'):
83 context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
84 context.verify_mode = ssl.CERT_NONE
85 service_instance = connect.SmartConnect(host=args.host,
86 user=args.user,
87 pwd=args.password,
88 port=int(args.port),
89 sslContext=context)
90 # the recording will show up in the working directory
91

Tack så mycket!

lmcdasm commented Dec 21, 2015

Hey Gorantornqvist's method of creating a context and then assigning it worked for me in py and py3.

here is the hello world with yaml sample with it working.
4 import ssl
71 def main():
72 """
73 Simple command-line program for listing the virtual machines on a system.
74 """
75
76 args = get_args()
77
78 try:
79 my_vcr = vcr.VCR()
80 # use the vcr instance to setup an instance of service_instance
81 with my_vcr.use_cassette('hello_world_vcenter.yaml',
82 record_mode='all'):
83 context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
84 context.verify_mode = ssl.CERT_NONE
85 service_instance = connect.SmartConnect(host=args.host,
86 user=args.user,
87 pwd=args.password,
88 port=int(args.port),
89 sslContext=context)
90 # the recording will show up in the working directory
91

Tack så mycket!

@osher13l

This comment has been minimized.

Show comment
Hide comment
@osher13l

osher13l Dec 28, 2015

Thanks @gorantornqvist .

The only workaround that worked for me as well

Thanks @gorantornqvist .

The only workaround that worked for me as well

@lmcdasm

This comment has been minimized.

Show comment
Hide comment
@lmcdasm

lmcdasm Dec 28, 2015

Glad to hear it (and thanks to @gorantornqvist as well).

lmcdasm commented Dec 28, 2015

Glad to hear it (and thanks to @gorantornqvist as well).

@hartsock hartsock assigned tianhao64 and unassigned hartsock Dec 29, 2015

@nmadhok

This comment has been minimized.

Show comment
Hide comment
@nmadhok

nmadhok Jan 4, 2016

Contributor

The suggested workaround by @gorantornqvist will only work on systems with Python 2.7+ and pyVmomi 6.0.0. This will not work on systems with Python 2.6 or systems with pyVmomi < 6.0

Contributor

nmadhok commented Jan 4, 2016

The suggested workaround by @gorantornqvist will only work on systems with Python 2.7+ and pyVmomi 6.0.0. This will not work on systems with Python 2.6 or systems with pyVmomi < 6.0

@lmcdasm

This comment has been minimized.

Show comment
Hide comment
@lmcdasm

lmcdasm Jan 4, 2016

Hello.. I tested with python3 and was fine
On Jan 4, 2016 10:55 AM, "Nitin Madhok" notifications@github.com wrote:

The suggested workaround by @gorantornqvist
https://github.com/gorantornqvist will only work on systems with Python
2.7+. This will not work on systems with Python 2.6


Reply to this email directly or view it on GitHub
#235 (comment).

lmcdasm commented Jan 4, 2016

Hello.. I tested with python3 and was fine
On Jan 4, 2016 10:55 AM, "Nitin Madhok" notifications@github.com wrote:

The suggested workaround by @gorantornqvist
https://github.com/gorantornqvist will only work on systems with Python
2.7+. This will not work on systems with Python 2.6


Reply to this email directly or view it on GitHub
#235 (comment).

@vagrant-storm

This comment has been minimized.

Show comment
Hide comment
@vagrant-storm

vagrant-storm Jan 6, 2016

Can any one explain why any line after this give me a syntax error in Python 3.4?

try:
import ssl
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE

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

print ("logged in to %s" % args.host)

In that example the print statement is giving me an invalid syntax after I add the code from @gorantornqvist...before it works. I am still learning python...but I am certain everything I've tried was correct syntax. I've tried both typing and copying/pasting and I've verified the encoding is unchanged.

I can't seem to get any work around for this SSL error to work for me.

Bah, i give up...I can't believe Github doesn't use [code] tags. I cannot get this to format right, but my indents are correct.

Can any one explain why any line after this give me a syntax error in Python 3.4?

try:
import ssl
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE

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

print ("logged in to %s" % args.host)

In that example the print statement is giving me an invalid syntax after I add the code from @gorantornqvist...before it works. I am still learning python...but I am certain everything I've tried was correct syntax. I've tried both typing and copying/pasting and I've verified the encoding is unchanged.

I can't seem to get any work around for this SSL error to work for me.

Bah, i give up...I can't believe Github doesn't use [code] tags. I cannot get this to format right, but my indents are correct.

@lmcdasm

This comment has been minimized.

Show comment
Hide comment
@lmcdasm

lmcdasm Jan 6, 2016

hey there..

you need to indent under the try:

and then figure out if your Print you want as part of the try loop or
indent back (so its not).

Cheers,
D

On Tue, Jan 5, 2016 at 7:08 PM, vagrant-storm notifications@github.com
wrote:

Can any one explain why any line after this give me a syntax error in
Python 3.4?

try:
import ssl
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE

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

print ("logged in to %s" % args.host)

In that example the print statement is giving me an invalid syntax after I
add the code from @gorantornqvist https://github.com/gorantornqvist...before
it works. I am still learning python...but I fail to see what is going on
here. I've tried both typing and copying/pasting and I've verified the
encoding is unchanged.

I can't seem to get any work arround to for this SSL error to work for me.


Reply to this email directly or view it on GitHub
#235 (comment).

lmcdasm commented Jan 6, 2016

hey there..

you need to indent under the try:

and then figure out if your Print you want as part of the try loop or
indent back (so its not).

Cheers,
D

On Tue, Jan 5, 2016 at 7:08 PM, vagrant-storm notifications@github.com
wrote:

Can any one explain why any line after this give me a syntax error in
Python 3.4?

try:
import ssl
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE

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

print ("logged in to %s" % args.host)

In that example the print statement is giving me an invalid syntax after I
add the code from @gorantornqvist https://github.com/gorantornqvist...before
it works. I am still learning python...but I fail to see what is going on
here. I've tried both typing and copying/pasting and I've verified the
encoding is unchanged.

I can't seem to get any work arround to for this SSL error to work for me.


Reply to this email directly or view it on GitHub
#235 (comment).

@vagrant-storm

This comment has been minimized.

Show comment
Hide comment
@vagrant-storm

vagrant-storm Jan 6, 2016

Oops it didn't copy right. I do have all the indents as they should be. import ssl is indented and the print is not.

or it did copy right...if I hit edit all the indents are there...weird. I will have to play with the Git posting some more.

Oops it didn't copy right. I do have all the indents as they should be. import ssl is indented and the print is not.

or it did copy right...if I hit edit all the indents are there...weird. I will have to play with the Git posting some more.

@vagrant-storm

This comment has been minimized.

Show comment
Hide comment
@vagrant-storm

vagrant-storm Jan 6, 2016

is there any other way a person could get around this SSL: Cert failing? I've tried editing the adapters.py to be verify=false as well and there was no change.

Nevermind...I took out the try and it works.

is there any other way a person could get around this SSL: Cert failing? I've tried editing the adapters.py to be verify=false as well and there was no change.

Nevermind...I took out the try and it works.

@tcr-ableton

This comment has been minimized.

Show comment
Hide comment
@tcr-ableton

tcr-ableton Feb 3, 2016

I can confirm I am affected by this problem too: when using the vmware modules of ansible.

The workaround posted by @gorantornqvist (#235 (comment)) solves it in my case. I'm using python2.7.11 on osx.

Is there a problem solution planned? Can I help in any ways?

I can confirm I am affected by this problem too: when using the vmware modules of ansible.

The workaround posted by @gorantornqvist (#235 (comment)) solves it in my case. I'm using python2.7.11 on osx.

Is there a problem solution planned? Can I help in any ways?

@lmcdasm

This comment has been minimized.

Show comment
Hide comment
@lmcdasm

lmcdasm Feb 11, 2016

Can you copy/paste your script you are running of a screen shot / link of
the commands you are trying to do with some more info so we can see?

cheers,
z

On Thu, Feb 11, 2016 at 1:30 AM, chaitanyaanpate notifications@github.com
wrote:

I am simply trying to connect to vCenter but unable to connect
Using python 3.4 and pyvmomi 6.0.0
Above work arounds not helping to connect

C:\Python34\lib\site-packages\requests-2.8.1-py3.4.egg\requests\packages\urllib3\connectionpool.py:789:
InsecureRequestWarning: Unverified HTTPS request is being made. Adding
certificate verification is strongly advised. See:
https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
Traceback (most recent call last):
File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 307, in

_Login File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\VmomiSupport.py",
line 566, in File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\VmomiSupport.py",
line 375, in _InvokeMethod File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\SoapAdapter.py",
line 1254, in InvokeMethod File "C:\Python34\lib\http\client.py", line
1088, in request self._send_request(method, url, body, headers) File
"C:\Python34\lib\http\client.py", line 1126, in _send_request
self.endheaders(body) File "C:\Python34\lib\http\client.py", line 1084, in
endheaders self._send_output(message_body) File
"C:\Python34\lib\http\client.py", line 922, in _send_output self.send(msg)
File "C:\Python34\lib\http\client.py", line 857, in send self.connect()
File "C:\Python34\lib\http\client.py", line 1231, in connect
server_hostname=server_hostname) File "C:\Python34\lib\ssl.py", line 365,
in wrap_socket _context=self) File "C:\Python34\lib\ssl.py", line 583, in
_init
self.do_handshake()
File "C:\Python34\lib\ssl.py", line 810, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\canpate\workspace\Vcenter\Login.py", line 15, in
si = SmartConnect(host = 'purndlvc.global.avaya.com',user
='GLOBAL\canpate',pwd ='MotoG1033',port=443)
File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 590, in SmartConnect
File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 234, in Connect
File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 319, in

_Login File "C:\Python34\lib\site-packages\six.py", line 685, in reraise
raise value.with_traceback(tb) File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 307, in __Login File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\VmomiSupport.py",
line 566, in File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\VmomiSupport.py",
line 375, in _InvokeMethod File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\SoapAdapter.py",
line 1254, in InvokeMethod File "C:\Python34\lib\http\client.py", line
1088, in request self._send_request(method, url, body, headers) File
"C:\Python34\lib\http\client.py", line 1126, in _send_request
self.endheaders(body) File "C:\Python34\lib\http\client.py", line 1084, in
endheaders self._send_output(message_body) File
"C:\Python34\lib\http\client.py", line 922, in _send_output self.send(msg)
File "C:\Python34\lib\http\client.py", line 857, in send self.connect()
File "C:\Python34\lib\http\client.py", line 1231, in connect
server_hostname=server_hostname) File "C:\Python34\lib\ssl.py", line 365,
in wrap_socket _context=self) File "C:\Python34\lib\ssl.py", line 583, in
_init
self.do_handshake()
File "C:\Python34\lib\ssl.py", line 810, in do_handshake
self._sslobj.do_handshake()
pyVmomi.VmomiSupport.HostConnectFault: (vim.fault.HostConnectFault) {
dynamicType = ,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:600)',
faultCause = ,
faultMessage = (vmodl.LocalizableMessage) []
}


Reply to this email directly or view it on GitHub
#235 (comment).

lmcdasm commented Feb 11, 2016

Can you copy/paste your script you are running of a screen shot / link of
the commands you are trying to do with some more info so we can see?

cheers,
z

On Thu, Feb 11, 2016 at 1:30 AM, chaitanyaanpate notifications@github.com
wrote:

I am simply trying to connect to vCenter but unable to connect
Using python 3.4 and pyvmomi 6.0.0
Above work arounds not helping to connect

C:\Python34\lib\site-packages\requests-2.8.1-py3.4.egg\requests\packages\urllib3\connectionpool.py:789:
InsecureRequestWarning: Unverified HTTPS request is being made. Adding
certificate verification is strongly advised. See:
https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)
Traceback (most recent call last):
File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 307, in

_Login File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\VmomiSupport.py",
line 566, in File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\VmomiSupport.py",
line 375, in _InvokeMethod File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\SoapAdapter.py",
line 1254, in InvokeMethod File "C:\Python34\lib\http\client.py", line
1088, in request self._send_request(method, url, body, headers) File
"C:\Python34\lib\http\client.py", line 1126, in _send_request
self.endheaders(body) File "C:\Python34\lib\http\client.py", line 1084, in
endheaders self._send_output(message_body) File
"C:\Python34\lib\http\client.py", line 922, in _send_output self.send(msg)
File "C:\Python34\lib\http\client.py", line 857, in send self.connect()
File "C:\Python34\lib\http\client.py", line 1231, in connect
server_hostname=server_hostname) File "C:\Python34\lib\ssl.py", line 365,
in wrap_socket _context=self) File "C:\Python34\lib\ssl.py", line 583, in
_init
self.do_handshake()
File "C:\Python34\lib\ssl.py", line 810, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\canpate\workspace\Vcenter\Login.py", line 15, in
si = SmartConnect(host = 'purndlvc.global.avaya.com',user
='GLOBAL\canpate',pwd ='MotoG1033',port=443)
File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 590, in SmartConnect
File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 234, in Connect
File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 319, in

_Login File "C:\Python34\lib\site-packages\six.py", line 685, in reraise
raise value.with_traceback(tb) File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVim\connect.py",
line 307, in __Login File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\VmomiSupport.py",
line 566, in File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\VmomiSupport.py",
line 375, in _InvokeMethod File
"C:\Python34\lib\site-packages\pyvmomi-5.5.0_2014.1.1-py3.4.egg\pyVmomi\SoapAdapter.py",
line 1254, in InvokeMethod File "C:\Python34\lib\http\client.py", line
1088, in request self._send_request(method, url, body, headers) File
"C:\Python34\lib\http\client.py", line 1126, in _send_request
self.endheaders(body) File "C:\Python34\lib\http\client.py", line 1084, in
endheaders self._send_output(message_body) File
"C:\Python34\lib\http\client.py", line 922, in _send_output self.send(msg)
File "C:\Python34\lib\http\client.py", line 857, in send self.connect()
File "C:\Python34\lib\http\client.py", line 1231, in connect
server_hostname=server_hostname) File "C:\Python34\lib\ssl.py", line 365,
in wrap_socket _context=self) File "C:\Python34\lib\ssl.py", line 583, in
_init
self.do_handshake()
File "C:\Python34\lib\ssl.py", line 810, in do_handshake
self._sslobj.do_handshake()
pyVmomi.VmomiSupport.HostConnectFault: (vim.fault.HostConnectFault) {
dynamicType = ,
dynamicProperty = (vmodl.DynamicProperty) [],
msg = '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
(_ssl.c:600)',
faultCause = ,
faultMessage = (vmodl.LocalizableMessage) []
}


Reply to this email directly or view it on GitHub
#235 (comment).

@chaitanyaanpate

This comment has been minimized.

Show comment
Hide comment
@chaitanyaanpate

chaitanyaanpate Feb 11, 2016

CODE:(As it is)

import pyVmomi;
from pyVim import connect;
from pyVmomi import *;

print('welcome')

url='Myurl'
username='chaitanya'
password='Muypassword'

si = connect.SmartConnect(host=url,user=username,pwd=password,port=443)

CODE:(As it is)

import pyVmomi;
from pyVim import connect;
from pyVmomi import *;

print('welcome')

url='Myurl'
username='chaitanya'
password='Muypassword'

si = connect.SmartConnect(host=url,user=username,pwd=password,port=443)

@lmcdasm

This comment has been minimized.

Show comment
Hide comment
@lmcdasm

lmcdasm Feb 11, 2016

there is a bug, so here is a script that will work for you

#!/usr/bin/python

import ssl
import pyVmomi
from pyVim import connect
import vcr

from pyVmomi import *; < == you dont need this

def main():
"""
Simple command-line program for listing the virtual machines on a system.
"""
args = get_args()
try:
my_vcr = vcr.VCR()

use the vcr instance to setup an instance of service_instance

with my_vcr.use_cassette('hello_world_vcenter.yaml', record_mode='all'):
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE
service_instance = connect.SmartConnect(host=args.host,
user=args.user,
pwd=args.password,
port=int(args.port),
sslContext=context)

the recording will show up in the working directory

lmcdasm commented Feb 11, 2016

there is a bug, so here is a script that will work for you

#!/usr/bin/python

import ssl
import pyVmomi
from pyVim import connect
import vcr

from pyVmomi import *; < == you dont need this

def main():
"""
Simple command-line program for listing the virtual machines on a system.
"""
args = get_args()
try:
my_vcr = vcr.VCR()

use the vcr instance to setup an instance of service_instance

with my_vcr.use_cassette('hello_world_vcenter.yaml', record_mode='all'):
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE
service_instance = connect.SmartConnect(host=args.host,
user=args.user,
pwd=args.password,
port=int(args.port),
sslContext=context)

the recording will show up in the working directory

@chaitanyaanpate

This comment has been minimized.

Show comment
Hide comment
@chaitanyaanpate

chaitanyaanpate Feb 16, 2016

I am new to python and I am getting error as unexpected end of file error
also if indented its error undefined package yaml;undefined variable
get_args and unexpected EOF while parsing

On Thu, Feb 11, 2016 at 9:54 PM, lmcdasm notifications@github.com wrote:

there is a bug, so here is a script that will work for you

#!/usr/bin/python

import ssl
import pyVmomi
from pyVim import connect
import vcr
from pyVmomi import *; < == you dont need this

def main():
"""
Simple command-line program for listing the virtual machines on a system.
"""
args = get_args()
try:
my_vcr = vcr.VCR()
use the vcr instance to setup an instance of service_instance

with my_vcr.use_cassette('hello_world_vcenter.yaml', record_mode='all'):
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE

service_instance = connect.SmartConnect(host=args.host,
user=args.user,
pwd=args.password,
port=int(args.port),
sslContext=context)
the recording will show up in the working directory


Reply to this email directly or view it on GitHub
#235 (comment).

I am new to python and I am getting error as unexpected end of file error
also if indented its error undefined package yaml;undefined variable
get_args and unexpected EOF while parsing

On Thu, Feb 11, 2016 at 9:54 PM, lmcdasm notifications@github.com wrote:

there is a bug, so here is a script that will work for you

#!/usr/bin/python

import ssl
import pyVmomi
from pyVim import connect
import vcr
from pyVmomi import *; < == you dont need this

def main():
"""
Simple command-line program for listing the virtual machines on a system.
"""
args = get_args()
try:
my_vcr = vcr.VCR()
use the vcr instance to setup an instance of service_instance

with my_vcr.use_cassette('hello_world_vcenter.yaml', record_mode='all'):
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE

service_instance = connect.SmartConnect(host=args.host,
user=args.user,
pwd=args.password,
port=int(args.port),
sslContext=context)
the recording will show up in the working directory


Reply to this email directly or view it on GitHub
#235 (comment).

@lmcdasm

This comment has been minimized.

Show comment
Hide comment
@lmcdasm

lmcdasm Feb 16, 2016

hello.

You need to indent and follow proper python syntax. Perhaps start with the
Python Tutorial so you can see how the code should be laid out and the move
this code into your script.

On Tue, Feb 16, 2016 at 2:10 AM, chaitanyaanpate notifications@github.com
wrote:

I am new to python and I am getting error as unexpected end of file error
also if indented its error undefined package yaml;undefined variable
get_args and unexpected EOF while parsing

On Thu, Feb 11, 2016 at 9:54 PM, lmcdasm notifications@github.com wrote:

there is a bug, so here is a script that will work for you

#!/usr/bin/python

import ssl
import pyVmomi
from pyVim import connect
import vcr
from pyVmomi import *; < == you dont need this

def main():
"""
Simple command-line program for listing the virtual machines on a system.
"""
args = get_args()
try:
my_vcr = vcr.VCR()
use the vcr instance to setup an instance of service_instance

with my_vcr.use_cassette('hello_world_vcenter.yaml', record_mode='all'):
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE

service_instance = connect.SmartConnect(host=args.host,
user=args.user,
pwd=args.password,
port=int(args.port),
sslContext=context)
the recording will show up in the working directory


Reply to this email directly or view it on GitHub
#235 (comment).


Reply to this email directly or view it on GitHub
#235 (comment).

lmcdasm commented Feb 16, 2016

hello.

You need to indent and follow proper python syntax. Perhaps start with the
Python Tutorial so you can see how the code should be laid out and the move
this code into your script.

On Tue, Feb 16, 2016 at 2:10 AM, chaitanyaanpate notifications@github.com
wrote:

I am new to python and I am getting error as unexpected end of file error
also if indented its error undefined package yaml;undefined variable
get_args and unexpected EOF while parsing

On Thu, Feb 11, 2016 at 9:54 PM, lmcdasm notifications@github.com wrote:

there is a bug, so here is a script that will work for you

#!/usr/bin/python

import ssl
import pyVmomi
from pyVim import connect
import vcr
from pyVmomi import *; < == you dont need this

def main():
"""
Simple command-line program for listing the virtual machines on a system.
"""
args = get_args()
try:
my_vcr = vcr.VCR()
use the vcr instance to setup an instance of service_instance

with my_vcr.use_cassette('hello_world_vcenter.yaml', record_mode='all'):
context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
context.verify_mode = ssl.CERT_NONE

service_instance = connect.SmartConnect(host=args.host,
user=args.user,
pwd=args.password,
port=int(args.port),
sslContext=context)
the recording will show up in the working directory


Reply to this email directly or view it on GitHub
#235 (comment).


Reply to this email directly or view it on GitHub
#235 (comment).

@mgogoulos mgogoulos referenced this issue in mistio/mist-ce Feb 22, 2016

Closed

Vsphere Integration Does Not Work #691

@ritzk

This comment has been minimized.

Show comment
Hide comment
@ritzk

ritzk Mar 31, 2016

I use a lot more hackish workaround - http://khadgaray.blogspot.com/2016/03/python-disabling-ssl-verification-on.html , as we work with a combination of Python 2.6.6 and 2.7.10 .

ritzk commented Mar 31, 2016

I use a lot more hackish workaround - http://khadgaray.blogspot.com/2016/03/python-disabling-ssl-verification-on.html , as we work with a combination of Python 2.6.6 and 2.7.10 .

@poose

This comment has been minimized.

Show comment
Hide comment
@poose

poose Apr 1, 2016

There will be seven SSL certificate's. Any one among those seven can solve ur problem. Soon I ll share u the certificates.

poose commented Apr 1, 2016

There will be seven SSL certificate's. Any one among those seven can solve ur problem. Soon I ll share u the certificates.

@tianhao64

This comment has been minimized.

Show comment
Hide comment
@tianhao64

tianhao64 Apr 2, 2016

Contributor

This is already fixed by 92c1de5.

Contributor

tianhao64 commented Apr 2, 2016

This is already fixed by 92c1de5.

@tianhao64 tianhao64 closed this Apr 2, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment