Skip to content

Commit

Permalink
pass unverified sslcontext to bay pass server certificate verification
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianhao He committed Nov 30, 2015
1 parent 3d7a48a commit c88571b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
14 changes: 6 additions & 8 deletions sample/getallvms.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,12 @@

from __future__ import print_function

import pyVmomi

from pyVmomi import vim
from pyVmomi import vmodl

from pyVim.connect import SmartConnect, Disconnect
from pyVmomi import vmodl

import argparse
import atexit
import getpass

import ssl

def GetArgs():
"""
Expand Down Expand Up @@ -96,10 +90,14 @@ def main():
password = getpass.getpass(prompt='Enter password for host %s and '
'user %s: ' % (args.host,args.user))


context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_NONE
si = SmartConnect(host=args.host,
user=args.user,
pwd=password,
port=int(args.port))
port=int(args.port),
sslContext=context)
if not si:
print("Could not connect to the specified host using specified "
"username and password")
Expand Down
6 changes: 5 additions & 1 deletion sample/poweronvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import atexit
import getpass
import sys
import ssl

def GetArgs():
"""
Expand Down Expand Up @@ -113,11 +114,14 @@ def main():
sys.exit()

si = None
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_NONE
try:
si = SmartConnect(host=args.host,
user=args.user,
pwd=password,
port=int(args.port))
port=int(args.port),
sslContext=context)
except IOError:
pass
if not si:
Expand Down

0 comments on commit c88571b

Please sign in to comment.