diff --git a/pyVim/connect.py b/pyVim/connect.py index 5dc959f..a9cee20 100644 --- a/pyVim/connect.py +++ b/pyVim/connect.py @@ -271,6 +271,36 @@ def Connect(host='localhost', port=443, user='root', pwd='', return si +def ConnectNoSSL(host='localhost', port=443, user='root', pwd='', + service="hostd", adapter="SOAP", namespace=None, path="/sdk", + version=None, keyFile=None, certFile=None, thumbprint=None, + sslContext=None, b64token=None, mechanism='userpass'): + """ + 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. Will attempt to create an unverified + SSL context and then connect via the Connect method. + """ + + if hasattr(ssl, '_create_unverified_context'): + sslContext = ssl._create_unverified_context() + else: + sslContext = None + + return Connect(host=host, + port=portNumber, + user=user, + pwd=pwd, + service=service, + adapter='SOAP', + version=supportedVersion, + path=path, + keyFile=keyFile, + certFile=certFile, + thumbprint=thumbprint, + sslContext=sslContext, + b64token=b64token, + mechanism=mechanism) def Disconnect(si): """ @@ -804,7 +834,7 @@ def SmartConnect(protocol='https', host='localhost', port=443, user='root', pwd= b64token=b64token, mechanism=mechanism) -def ConnectNoSSL(protocol='https', host='localhost', port=443, user='root', pwd='', +def SmartConnectNoSSL(protocol='https', host='localhost', port=443, user='root', pwd='', service="hostd", path="/sdk", preferredApiVersions=None, keyFile=None, certFile=None, thumbprint=None, sslContext=None, b64token=None, mechanism='userpass'):