简体   繁体   English

在python中抑制'SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败'错误

[英]Suppress 'SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' errors in python

I am having trouble using pyVmomi with python 2.7.5. 我在使用python 2.7.5的pyVmomi时遇到了麻烦。 I get SSL certificate errors when trying to run the sample scripts from the SDK. 尝试从SDK运行示例脚本时,我收到SSL证书错误。 I tried all the solutions mentioned on this post but none of them worked for me. 我尝试了这篇文章中提到的所有解决方案,但没有一个对我有用。

Below is the complete console output. 以下是完整的控制台输出。

/usr/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:315: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning. SNIMissingWarning /usr/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:120: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. InsecurePlatformWarning

Traceback (most recent call last):
  File "hello_world_vcenter.py", line 105, in <module>
    main()
  File "hello_world_vcenter.py", line 80, in main
    port=int(args.port))
  File "/usr/lib/python2.7/site-packages/pyVim/connect.py", line 663, in SmartConnect
    sslContext)
  File "/usr/lib/python2.7/site-packages/pyVim/connect.py", line 552, in __FindSupportedVersion
    sslContext)
  File "/usr/lib/python2.7/site-packages/pyVim/connect.py", line 472, in __GetServiceVersionDescription
    tree = __GetElementTreeFromUrl(url, sslContext)
  File "/usr/lib/python2.7/site-packages/pyVim/connect.py", line 440, in __GetElementTreeFromUrl
    sock = requests.get(url)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 447, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno 1] _ssl.c:504: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

That looks like you're using a self-signed certificate. 看起来您正在使用自签名证书。 While connecting via SmartConnect use your own sslContext and disable certificate verification. 通过SmartConnect连接时,请使用您自己的sslContext并禁用证书验证。

from pyVim.connect import SmartConnect
import ssl

context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
context.verify_mode = ssl.CERT_NONE

si = SmartConnect(host=somehost.com, port=443, user=someone, pwd=secret, sslContext=context)

... or use a signed ssl certificate. ...或使用签名的ssl证书。

There are a few similiar questions on here (eg here ). 这里有几个类似的问题(例如这里 )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python Twisted:SSL例程,ssl3_get_server_certificate错误 - Python Twisted : SSL routines , ssl3_get_server_certificate errors SSL错误:例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - SSL error : routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 身份验证失败:[Errno 1] _ssl.c:510:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - Authentication failed: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed SSLError:[Errno 1] _ssl.c:510:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败 - SSLError: [Errno 1] _ssl.c:510: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed 请求(仅)* .google.com时,SSL上的SSL3_GET_SERVER_CERTIFICATE证书验证失败 - SSL3_GET_SERVER_CERTIFICATE certificate verify failed on Python when requesting (only) *.google.com Python:Ssl 证书验证失败 - Python: Ssl Certificate verify failed Hashicorp python 客户端暖通空调问题:-“握手错误:错误([(&#39;SSL 例程&#39;,&#39;tls_process_server_certificate&#39;,&#39;证书验证失败&#39; - Hashicorp python client hvac issue:- "bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed' Django paypalrestsdk错误-OpenSSL.SSL.Error:[(“ SSL例程”,“ tls_process_server_certificate”,“证书验证失败”)) - Django paypalrestsdk error - OpenSSL.SSL.Error: [('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')] SSL:CERTIFICATE_VERIFY_FAILED 证书验证在 Python 中失败 - SSL: CERTIFICATE_VERIFY_FAILED certificate verify failed in Python SSL:CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c:1108) Discord/python - SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108) Discord/python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM