vmware / vsphere-automation-sdk-python

Python samples, language bindings, and API reference documentation for vSphere, VMC, and NSX-T using the VMware REST API
MIT License
745 stars 313 forks source link

Failure to Create Session with vSphere Client Using Self-Signed Certificate #419

Closed AradCarmi closed 4 months ago

AradCarmi commented 5 months ago

Describe the bug

The create_vsphere_client function encountered an issue when attempting to establish a session with a self-signed server, despite having the session object configured with verify=False. This failure was triggered by an SSLError, specifically an SSLZeroReturnError (error code 6), indicating that the TLS/SSL connection was closed unexpectedly (EOF) at line 997

Reproduction steps

  1. Create a self-signed server.
  2. Create a Session object with session.verify=false.
  3. create a Python script calling the create_vsphere_client with server, username&password, and session.
  4. Run the script.

Expected behavior

The created session will allow us to connect the VMware Vcenter server even if the server is a self-signed certificate.

Additional context

No response

bhagatp10 commented 5 months ago

Hi, AFAIK, VC certificates cannot be updated with self signed certificates. Can you tell me what exactly are you trying to do? If you want to verify the SSL cert then why are you setting session.verify=false

AradCarmi commented 5 months ago

Hey @bhagatp10 thank you for the fast response! My VC server is updated with self-signed certificates and it is working fine. I'm trying to retrieve some data using the Client and I want the Client not to verify my certificate when creating the session. As I mentioned before, I tried to send a session object to the Client with the right configuration but from viewing the Client code it ignored this configuration.

bhagatp10 commented 5 months ago

Hi, Can you show me the snippet of the code you are using?

AradCarmi commented 5 months ago

Sure. image

kunalpmj commented 5 months ago

What python version you are using? What are the urllib3 and openssl version?

AradCarmi commented 5 months ago

python version 3.10.14 urllib3 version 2.2.1

kunalpmj commented 4 months ago

Kindly refer to following troubleshooting section.

https://github.com/vmware/vsphere-automation-sdk-python/wiki/Troubleshooting#certificate-verification-failed-when-making-api-calls