httpx icon indicating copy to clipboard operation
httpx copied to clipboard

SSL: WRONG_VERSION_NUMBER

Open sweety3377 opened this issue 4 years ago • 5 comments
trafficstars

Checklist

  • [ ] The bug is reproducible against the latest release and/or master.
  • [ ] There are no similar issues or pull requests to fix it yet.

Describe the bug

Code

def main(): auth_login = 'test1' auth_password = 'test2' proxy_headers = { "Authorization": generate_basic_header(auth_login, auth_password), "Client": 'CLIENT_HERE', "Connection": 'keep-alive', "Server-Name": 'httpbin.org', "Host": 'IP_HERE', "Secure": '1', "HTTP2": '1', } proxy_url = 'http://IP:PORT' proxy_mode = 'TUNNEL_ONLY' timeout = Timeout(read=10, connect=5, timeout=5) proxy = Proxy(url=proxy_url, headers=proxy_headers, mode=proxy_mode) with Client(http2=True, verify=False, proxies=proxy, timeout=timeout) as client: request_url = 'https://httpbin.org/get' r = client.get(url=request_url) print(r.text)

Traceback

Traceback (most recent call last): File "C:/Users/Test/Desktop/Engine/tests/tls-tunneling.py", line 53, in main() File "C:/Users/Test/Desktop/Engine/tests/tls-tunneling.py", line 48, in main r = client.get(url=request_url) File "C:\Users\Test\AppData\Roaming\Python\Python38\site-packages\httpx_client.py", line 907, in get return self.request( File "C:\Users\Test\AppData\Roaming\Python\Python38\site-packages\httpx_client.py", line 733, in request return self.send( File "C:\Users\Test\AppData\Roaming\Python\Python38\site-packages\httpx_client.py", line 767, in send response = self._send_handling_auth( File "C:\Users\Test\AppData\Roaming\Python\Python38\site-packages\httpx_client.py", line 805, in _send_handling_auth response = self._send_handling_redirects( File "C:\Users\Test\AppData\Roaming\Python\Python38\site-packages\httpx_client.py", line 837, in _send_handling_redirects response = self._send_single_request(request, timeout) File "C:\Users\Test\AppData\Roaming\Python\Python38\site-packages\httpx_client.py", line 861, in _send_single_request (status_code, headers, stream, ext) = transport.request( File "C:\Program Files\Python38\lib\contextlib.py", line 131, in exit self.gen.throw(type, value, traceback) File "C:\Users\Test\AppData\Roaming\Python\Python38\site-packages\httpx_exceptions.py", line 343, in map_exceptions raise mapped_exc(message, **kwargs) from exc # type: ignore httpx.ProxyError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1124)

Environment

  • OS: Windows 10
  • Python version: Python 3.8.1
  • HTTPX version: 0.16.1
  • HTTP proxy: Yes
  • Custom certificates: No

Im use my HTTP proxy for custom TLS, i have a problems with TUNNEL_ONLY

sweety3377 avatar Jan 16 '21 23:01 sweety3377

@Sweety133 Hi,

In my mind there are two possibilities, that basically depend on what we do when using TUNNEL_ONLY with an http:// proxy URL.

  • If we connect via HTTP (as we should), then it's possible your proxy is in fact an HTTPS one, and we don't support that for now (see related issue).
  • If we connect via HTTPS (I don't think that's the case!), then you might want to try dropping TUNNEL_ONLY so HTTPX uses the default.

It's also possible that HTTPS CONNECT is forced because of http2=True. Does it replicate if you drop it so that HTTPX uses standard HTTP/1.1?

florimondmanca avatar Jan 17 '21 19:01 florimondmanca

My Tunnel support HTTP 2.0, TLS 1.1/1.2/1.3 My Tunnel its HTTP PROXY SERVER I have same error without HTTP 2.0

sweety3377 avatar Feb 07 '21 15:02 sweety3377

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 20 '22 15:02 stale[bot]

I'd like to take a look before we consider if this needs closing.

lovelydinosaur avatar Feb 21 '22 13:02 lovelydinosaur

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 25 '22 07:03 stale[bot]

Let's treat this as stale - we can have another look if it gets bought up by anyone again.

lovelydinosaur avatar Oct 06 '22 19:10 lovelydinosaur