---
title: "How to Fix SSL Handshake Errors Through a Proxy: 6 Causes"
description: "An SSL handshake error through a proxy usually comes from https:// in the proxy URL, the wrong port or a TLS-inspecting network. Six causes, first checks."
url: https://proxynet.io/blog/proxy-ssl-handshake-error
date: 2026-12-01
author: "Acar Diveroli"
category: "Tutorial"
lang: en
---

# How to Fix SSL Handshake Errors Through a Proxy: 6 Causes

An SSL handshake error means the client and the server cannot agree on the settings of the encrypted connection. When this error comes through a proxy, the cause is usually the proxy settings, not the certificate. For an HTTPS request, the proxy only opens a tunnel. The handshake happens inside that tunnel, between you and the target site. This post explains where the handshake takes place, the six causes of the error and how to fix each one.

> **Note: Short answer**
>
> First write the proxy URL with `http://`: even when the target is HTTPS, you reach the proxy over plain HTTP and the handshake happens with the target inside the tunnel. If the error persists, read the message for the cause: port, TLS inspection on the network, TLS version, SNI or the system clock.

## Where the handshake happens

A client going to an HTTPS target first sends the proxy a plain-text `CONNECT` request. The request holds only the target's name and port: `CONNECT good.test:443`. The proxy opens a TCP connection to the target and answers with `200`. Under RFC 9110, from that moment the proxy relays bytes in both directions without interpreting them.

The TLS handshake starts inside this tunnel. The client sends the first message to the target, the target presents the certificate, and the client validates it. A proxy that opens a plain tunnel never sees the certificate and cannot change it. In our test, `curl -v` showed the two stages on separate lines (shortened):

```text
> CONNECT good.test:443 HTTP/1.1
> Host: good.test:443
< HTTP/1.1 200 Connection established
* CONNECT tunnel established, response 200
* schannel: added 1 certificate(s) from CA file 'certs/ca.pem'
* schannel: connection hostname (good.test) validated against certificate name (good.test)
> GET / HTTP/1.1
```

Diagnosis rests on this split. An error before the `200` is about the proxy connection. An error after the `200` comes from the TLS conversation between you and the target. An [HTTPS Proxy](https://proxynet.io/https-proxy) also reaches HTTPS targets through this tunnel, so the rules below apply there too.

## https:// in the proxy URL

The most common cause is writing the proxy URL with `https://`. The scheme in the proxy URL describes your connection to the proxy, not the target. When the client sees `https://`, it starts speaking TLS to the proxy itself. A proxy listening on plain HTTP does not understand that message and returns `400 Bad Request`. The client tries to read that plain text as a TLS record, and the handshake fails.

In our test, Python requests gave this error:

```text
requests.exceptions.ProxyError: HTTPSConnectionPool(host='good.test', port=443): Max retries exceeded with url: / (Caused by ProxyError('Unable to connect to proxy. Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#https-proxy-error-http-proxy', SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1032)'))))
```

curl on Windows reacted to the same mistake with a different message. The description after the code is printed in the system language, so only the code is shown:

```text
curl: (35) schannel: next InitializeSecurityContext failed: SEC_E_INVALID_TOKEN (0x80090308)
```

The fix is one character. In both keys the URL starts with `http://`:

```python
import requests

proxies = {
    "http": "http://user:pass@pr.proxynet.io:8000",
    "https": "http://user:pass@pr.proxynet.io:8000",  # http:// even when the target is HTTPS
}
r = requests.get("https://example.com/", proxies=proxies, timeout=15)
print(r.status_code)
```

```bash
curl -x http://user:pass@pr.proxynet.io:8000 https://example.com/
```

If the URL comes from the `HTTPS_PROXY` environment variable rather than code, the same mistake sits there. All the settings, environment variables and SOCKS5 included, are in [How to Use a Proxy With Python Requests](/blog/python-requests-proxy). If the proxy itself listens on TLS, `https://` is correct, but that is a separate setup and the provider states it clearly.

## Wrong port and protocol

Point an HTTP client at a SOCKS5 port and the server does not recognize the `CONNECT` line, so it drops the connection. This error never reaches TLS. Many people still take it for a handshake problem, because it shows up in the first step of an HTTPS request.

The mismatch in both directions produced these outputs:

```text
# http:// URL, SOCKS5 port
curl: (56) Recv failure: Connection was reset
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, ...))

# socks5h:// URL, HTTP proxy port
curl: (97) Received invalid version in initial SOCKS5 response.
... Failed to establish a new connection: SOCKS5 proxy server sent invalid data
```

`10054` is the Windows code for a connection reset. Pick the scheme by port: `http://` for the HTTP port, `socks5h://` for the SOCKS5 port. Requests needs the `requests[socks]` package for SOCKS.

## A TLS-inspecting middlebox

Security appliances on some corporate networks decrypt HTTPS traffic and encrypt it again. The appliance terminates the tunnel itself and presents a certificate for the target, signed with its own root certificate. If that root is not installed on your device, validation fails. The error persists even when your proxy settings are correct.

We set up a local proxy that mimics this behavior. Its chain ended in an untrusted root named "Corporate TLS Inspection CA":

```text
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1032)
curl: (60) schannel: the certificate or certificate chain is based on an untrusted root
```

The first check is who signed the certificate. If the issuer is not a known certificate authority but carries the name of your company or a security product, the traffic is being inspected. The fix is to get the corporate root certificate from your IT team and point the client at it: `verify="corp-ca.pem"` or `--cacert corp-ca.pem`. In our test, the same request returned `200` once the corporate root was passed with `verify`.

Adding the root to the system store or merging it into a bundle differs by tool. The steps for Python, Node.js, Git and curl are in [Unable to Get Local Issuer Certificate: Causes and Fixes](/blog/unable-to-get-local-issuer-certificate).

## Old TLS and cipher suites

If the two sides cannot agree on a TLS version and cipher suite, the handshake ends in the first messages. TLS 1.0 and 1.1 were deprecated by RFC 8996 in 2021. Neither client in our test offered TLS 1.0. A server that spoke only TLS 1.0 failed on both:

```text
[SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:1032)
curl: (35) schannel: next InitializeSecurityContext failed: SEC_E_UNSUPPORTED_FUNCTION (0x80090302)
```

A cipher suite mismatch is sneakier, because the result depends on the client. Our TLS 1.2 server, which offered only the old `AES128-SHA` suite, gave this error in Python:

```text
[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] ssl/tls alert handshake failure (_ssl.c:1032)
```

curl on Windows connected to the same server and got a response. So "it works in curl but not in Python" may point not to the proxy but to two clients with different cipher lists. The fix is on the server side: TLS 1.2 or 1.3 and current suites. If the server is not yours, do not lower the client's security level. Tell the site owner.

## SNI and the system clock

SNI is the extension in which the client names the domain it wants in the first TLS message. A server hosting many sites on one IP picks the right certificate by that name. RFC 6066 does not allow an IP address in this field. If you use an IP instead of a domain in the URL, the client sends no SNI.

Our test server, which rejects handshakes without SNI, gave these errors:

```text
[SSL: TLSV1_UNRECOGNIZED_NAME] tlsv1 unrecognized name (_ssl.c:1032)
curl: (35) schannel: next InitializeSecurityContext failed: SEC_E_ILLEGAL_MESSAGE (0x80090326)
```

Going to the same server by the name `https://sni.test/` let the request through. Use the domain in the URL. The proxy settings have nothing to do with this error.

The clock problem also shows up in certificate validation. A certificate has a start and an end date, and the client compares them with its own clock. If the clock runs ahead, a valid certificate looks expired. If it runs behind, a new certificate is not yet valid. We reproduced both cases with certificates whose dates were shifted:

```text
certificate verify failed: certificate has expired (_ssl.c:1032)
certificate verify failed: certificate is not yet valid (_ssl.c:1032)
curl: (60) schannel: this certificate or one of the certificates in the certificate chain is not time valid
```

curl showed both cases with one message. If the error appears on many sites at once, check the system clock and time zone first.

## Debugging

The first diagnostic question is whether the tunnel opened. Look for the `CONNECT tunnel established, response 200` line in the `curl -v` output. If it is missing, the problem is in the proxy connection, authentication or the port. In that case the checks in [err_tunnel_connection_failed](/blog/err-tunnel-connection-failed) help. If the line is there, the problem is in the TLS conversation with the target.

```bash
curl -v -o /dev/null -x http://user:pass@pr.proxynet.io:8000 https://example.com/
```

You can also see the target's TLS setup without the proxy. A plain tunnel does not touch the certificate. The issuer you see on a direct connection is usually the same one you see in the tunnel. If they differ, a device sits in between.

```bash
openssl s_client -connect example.com:443 -servername example.com -brief </dev/null
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | openssl x509 -noout -issuer -dates
```

The first command prints the negotiated TLS version and the validation result, the second the issuer and the validity dates. We collected the messages from our tests in one table:

| Error message | Likely cause | First check |
|---|---|---|
| `wrong version number`, `SEC_E_INVALID_TOKEN` | `https://` in the proxy URL | Change the scheme to `http://` |
| `Connection was reset`, `invalid version in initial SOCKS5 response` | Wrong port or protocol | Match port and scheme |
| `self-signed certificate in certificate chain`, `untrusted root` | TLS-inspecting middlebox | The certificate issuer |
| `tlsv1 alert protocol version`, `SEC_E_UNSUPPORTED_FUNCTION` | Old TLS version | The server's TLS version |
| `alert handshake failure` | Cipher suite mismatch | Try another client |
| `tlsv1 unrecognized name`, `SEC_E_ILLEGAL_MESSAGE` | No SNI sent | A domain, not an IP, in the URL |
| `certificate has expired`, `not yet valid`, `not time valid` | Clock or expired certificate | System clock, then the dates |

> **Warning: verify=False and -k are not a fix**
>
> Turning validation off (`verify=False`, `curl -k`) is for diagnosis only: if the error goes away, the problem is in certificate validation. With this setting, any device in between can read and change the traffic. In our test it hid the certificate error, but the TLS version and SNI errors stayed exactly as they were.

## How we tested

We ran the tests on December 1, 2026, on Windows 11. The clients were Python 3.13.17, requests 2.34.2, urllib3 2.6.3 (OpenSSL 3.5.9) and the Windows build of curl 8.22.0 (Schannel). With Python we set up a plain HTTP CONNECT proxy on 127.0.0.1, a TLS-inspecting proxy, a minimal SOCKS5 server and six target servers.

Each target carried a single fault: TLS 1.0, `AES128-SHA` only, required SNI, an expired certificate and a not-yet-valid one. We issued the certificates from our own test root and passed it to the clients with `verify` or `--cacert`. Since the test root had no revocation list, we added `--ssl-no-revoke` to curl. The proxy returned `400 Bad Request` when the first byte was not an HTTP method. This local proxy stood in for `pr.proxynet.io:8000` in the examples. Windows error descriptions are in the system language, so we quote only the code.

## The bottom line

Write the proxy URL with `http://`, match the port to the protocol, and use `curl -v` to see first whether the tunnel opened. If it did, the problem is between you and the target: issuer, TLS version, SNI and clock. On a gateway like [Residential Proxy](https://proxynet.io/residential-proxy) the exit IP changes, but the site's certificate does not. Above all, do not turn validation off for good: that removes the protection, not the error.

## Sources

- [RFC 9110, §9.3.6 CONNECT: rfc-editor.org](https://www.rfc-editor.org/rfc/rfc9110#section-9.3.6)
- [RFC 6066, §3 Server Name Indication: rfc-editor.org](https://www.rfc-editor.org/rfc/rfc6066#section-3)
- [RFC 8996, Deprecating TLS 1.0 and TLS 1.1: datatracker.ietf.org](https://datatracker.ietf.org/doc/html/rfc8996)
- [urllib3, Your proxy appears to only use HTTP and not HTTPS: urllib3.readthedocs.io](https://urllib3.readthedocs.io/en/latest/advanced-usage.html#https-proxy-error-http-proxy)
- [curl, TLS Certificate Verification: curl.se](https://curl.se/docs/sslcerts.html)

## Frequently asked questions

### Is an SSL handshake error caused by the proxy?

Sometimes. Writing `https://` in the proxy URL or using the wrong port produces the error on the proxy side. An error that appears after the tunnel opens is between you and the target site. If the `curl -v` output has the `CONNECT tunnel established, response 200` line, the proxy has done its job. At that point, look at the certificate, TLS version, SNI and system clock.

### Why does the proxy URL start with http:// for an HTTPS site?

Because the scheme describes the connection to the proxy, not the target. The client sends the proxy a `CONNECT` request over plain HTTP. Once the proxy opens the tunnel, encryption is set up with the target inside it. If the proxy itself does not listen on TLS, writing `https://` means talking to it in a language it does not understand. In Python this shows up as `wrong version number`.

### What does the wrong version number error mean?

It means the client expected a TLS record and got something else. With a proxy, the most common cause is calling a plain HTTP proxy with `https://`. The proxy does not understand the TLS message and returns a plain-text `400`. When the client tries to read that text as a TLS record, the version field makes no sense. Changing the scheme to `http://` fixes it.

### If verify=False makes the error go away, is the problem solved?

No. If the error goes away, you have learned that the problem is in certificate validation, nothing more. With this setting, a device in between can read and change the traffic. In our test it hid the certificate error but did not fix the TLS version and SNI errors. The lasting fix is to trust the right root certificate or correct the cause.

### Why does the SSL error only appear on a company network with the proxy on?

Usually a security appliance on the network decrypts the traffic and re-signs it with its own certificate. Your browser often trusts the root certificate IT installed, but your script or curl may use its own store. Check the certificate issuer. If it carries your company's name, get the root from your IT team and pass it with `verify` or `--cacert`.

### Can the system clock cause an SSL error?

Yes. The client compares the certificate's start and end dates with its own clock. If the clock runs ahead you see `certificate has expired`, if it runs behind `certificate is not yet valid`. curl on Windows reports both as `not time valid`. If the error appears on many sites at once, fix the clock and time zone first.
