From dccb1c3375c4369989845762073f296c78855ede Mon Sep 17 00:00:00 2001 From: Stacy Brock Date: Thu, 30 Jan 2014 14:29:57 -0800 Subject: [PATCH] Fix SSL error when connecting from behind a proxy In certain versions of python, urllib fails when making https requests from behind a proxy. See http://bugs.python.org/issue1424152 for details. This patch fixes an issue with pyVim by using urllib2 instead of urllib, a change similar to existing code (see OpenUrlWithBasicAuth() and OpenPathWithStub()). --- pyVim/connect.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pyVim/connect.py b/pyVim/connect.py index c6b3499..b39c27d 100644 --- a/pyVim/connect.py +++ b/pyVim/connect.py @@ -427,9 +427,11 @@ def __GetServiceVersionDescription(protocol, server, port, path): tree = ElementTree() + import urllib2 + url = "%s://%s:%s/%s/vimServiceVersions.xml" % (protocol, server, port, path) try: - with closing(urllib.urlopen(url)) as sock: + with closing(urllib2.urlopen(url)) as sock: if sock.getcode() == 200: tree.parse(sock) return tree @@ -438,7 +440,7 @@ def __GetServiceVersionDescription(protocol, server, port, path): url = "%s://%s:%s/%s/vimService.wsdl" % (protocol, server, port, path) try: - with closing(urllib.urlopen(url)) as sock: + with closing(urllib2.urlopen(url)) as sock: if sock.getcode() == 200: tree.parse(sock) return tree