Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmware: fix python 2.7.9 < with if validate_certs false #57185

wants to merge 1 commit into
base: devel
Changes from all commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.


Just for now

vmware: not ssl.SSLContext if validate_certs false

Python < 2.7.9 does not have the ssl.SSLContext attribute.
ssl.SSLContext is only required when we want to validate the SSL
connection. If `validate_certs` is false, we don't initialize the
`ssl_context` variable.

closes: #57072
  • Loading branch information...
goneri committed May 30, 2019
commit 959bce68f6dfad7d67e556c13e0c34d3ef1404e7
@@ -515,12 +515,17 @@ def connect_to_api(module, disconnect_atexit=True):
if validate_certs and not hasattr(ssl, 'SSLContext'):
module.fail_json(msg='pyVim does not support changing verification mode with python < 2.7.9. Either update '
'python or use validate_certs=false.')

ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
if validate_certs:
elif validate_certs:
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ssl_context.verify_mode = ssl.CERT_REQUIRED
ssl_context.check_hostname = True
elif hasattr(ssl, 'SSLContext'):
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ssl_context.verify_mode = ssl.CERT_NONE
ssl_context.check_hostname = False
else: # Python < 2.7.9 or RHEL/Centos < 7.4
ssl_context = None

service_instance = None
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.