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

Connection to vCenter Server via authenticated proxy server fails #1022

Closed
VedaNiks opened this issue May 30, 2023 · 1 comment
Closed

Connection to vCenter Server via authenticated proxy server fails #1022

VedaNiks opened this issue May 30, 2023 · 1 comment

Comments

@VedaNiks
Copy link

Is your feature request related to a problem? Please describe.

I need to connect to vCenter server via authenticated proxy. But, I could not do so using SmartConnect.
I know, I need to send Proxy-Authorization header in the SmartConnect request but I couldn't find a way to do this.
I tried putting it in customHeaders attribute as given below:

custom_headers = {"Proxy-Authorization": "Basic c3F1aWRfdXNlcjpwYXNzd29yZA=="}
si = SmartConnect(host=vcenter_address,
user='administrator@vsphere.local',
pwd=password,
sslContext=context,
httpProxyHost=squid_proxy_server_address,
httpProxyPort=port,
customHeaders=custom_headers)

On executing above code I see below error:

Traceback (most recent call last):
  File "connect_to_vc.py", line 19, in <module>
    si = SmartConnect(host=vcenter_address
  File "/usr/local/lib/python3.8/dist-packages/pyVim/connect.py", line 939, in SmartConnect
    supportedVersion = __FindSupportedVersion(protocol, host, port, path,
  File "/usr/local/lib/python3.8/dist-packages/pyVim/connect.py", line 763, in __FindSupportedVersion
    serviceVersionDescription = __GetServiceVersionDescription(
  File "/usr/local/lib/python3.8/dist-packages/pyVim/connect.py", line 694, in __GetServiceVersionDescription
    return __GetElementTree(protocol, server, port,
  File "/usr/local/lib/python3.8/dist-packages/pyVim/connect.py", line 655, in __GetElementTree
    conn.request("GET", path)
  File "/usr/lib/python3.8/http/client.py", line 1256, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1302, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1251, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.8/http/client.py", line 1011, in _send_output
    self.send(msg)
  File "/usr/lib/python3.8/http/client.py", line 951, in send
    self.connect()
  File "/usr/lib/python3.8/http/client.py", line 1418, in connect
    super().connect()
  File "/usr/lib/python3.8/http/client.py", line 927, in connect
    self._tunnel()
  File "/usr/lib/python3.8/http/client.py", line 905, in _tunnel
    raise OSError("Tunnel connection failed: %d %s" % (code,
OSError: Tunnel connection failed: 407 Proxy Authentication Required

Is authenticated proxy supported in pyvmomi? If not, can you please guide me how I can do this using pyvmomi?

Describe the solution you'd like

Add authenticated proxy support in pyvmomi.

Describe alternatives you've considered

None

Additional context

No response

@VedaNiks
Copy link
Author

VedaNiks commented Jun 2, 2023

Hello,
Can anyone tell me if there is a way to use authenticated proxy server with pyVmomi?

@VedaNiks VedaNiks changed the title Connection to vCenter Server via authenticated proxy server fails Connection to vCenter Server via authenticated proxy server fails [VMware Staff Assist Needed] Jun 2, 2023
@VedaNiks VedaNiks changed the title Connection to vCenter Server via authenticated proxy server fails [VMware Staff Assist Needed] Connection to vCenter Server via authenticated proxy server fails Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant