How to Diagnose a Proxy TLS Certificate Error

A proxy TLS error can occur while your client connects to the proxy or while it verifies the destination certificate. Compare a direct cURL request with a proxied request to pinpoint where the verification failed.

Two connected rack servers beside certificate cards, one with a cracked seal

Find the connection that fails

Start with the exact proxy URL from your provider. Its scheme tells you how your client connects to the proxy. The destination URL tells you where the request goes.

  • With an http:// proxy and an https:// website, the proxy opens a CONNECT tunnel. Your client then starts TLS through that tunnel and verifies the website certificate.
  • With an https:// proxy and an https:// website, the client validates the proxy certificate before it sends CONNECT. After the tunnel opens, it validates the certificate presented for the destination in a second TLS handshake.
  • With a conventional SOCKS5 proxy, the client first negotiates SOCKS5. The TLS handshake for an HTTPS website follows that negotiation.

Make sure the protocol in your configuration matches the listener on the given port. Selecting https:// for a proxy that expects plain HTTP can produce a handshake error before certificate verification even starts. HTTP, HTTPS and SOCKS5 proxy protocols

Compare a direct request with a proxied request

Run both commands from the same machine and use the same destination. The first call bypasses proxies. In the second, replace the example gateway with your provider’s hostname, port and scheme. These examples use a public IP lookup that returns a small JSON response. On Windows, run curl.exe if your shell uses curl as an alias.

curl --disable --noproxy "*" --verbose --max-time 20 https://testmyproxies.com/api/my-ip
curl --disable --noproxy "localhost" --verbose --max-time 20 --proxy "http://gateway.example:8080" https://testmyproxies.com/api/my-ip

The second command replaces the bypass list with localhost for this test, so it still sends the public URL through your specified proxy. If you use an authenticated proxy, supply the credentials using your normal workflow. Before sharing a verbose trace, remove any authorization headers, cookies and private addresses.

In the trace, locate the proxy’s reply to CONNECT. A successful tunnel is commonly shown as 200 Connection established. With an HTTPS proxy, a certificate error before the tunnel reply can be on the proxy connection. A certificate error during the handshake after that reply points to the connection through the tunnel. A 407 from CONNECT calls for checking authentication first.

Check the hostname, dates and certificate chain

  1. Hostname. Connect using the provider’s documented DNS name for the HTTPS proxy. A certificate issued to gateway.example can fail name verification if you use the gateway’s IP. On the destination side, compare the URL hostname with the names covered by its certificate.
  2. Validity dates. Check the certificate’s start and expiry dates and the client’s system clock. If you manage the server, check the certificate its active listener presents after a renewal.
  3. Issuer and chain. An unknown issuer can be caused by a missing intermediate certificate, or by a private CA that the client has yet to trust. Compare the certificate path in the failing client with a working client. If a browser works and a container fails, check the trust stores separately.

If a managed proxy performs TLS inspection, it can present a different certificate for the destination. Verify the issuer with the network administrator and use the CA bundle supplied through your organization’s approved channel. How curl verifies certificates

Use the CA bundle for the connection you’re testing

With a curl build that supports HTTPS proxy verification, --proxy-cacert supplies trusted CA certificates for the HTTPS proxy itself. Replace proxy-ca.pem with the approved PEM bundle for that proxy.

curl --disable --noproxy "localhost" --max-time 20 --proxy "https://gateway.example:8443" --proxy-cacert proxy-ca.pem https://testmyproxies.com/api/my-ip

Use --cacert for the TLS connection to the destination, including when a managed inspection proxy presents a certificate for that hostname. Keep verification enabled so the test confirms both the certificate chain and the hostname. curl’s HTTPS proxy CA option

Read Cloudflare 525 and 526 separately

If the browser or tester receives an actual HTTP 525 or 526 error page from Cloudflare, it received an HTTP response from the edge. For those errors, the site operator needs to check the connection from Cloudflare to the origin and the certificate the origin presents. Cloudflare 525 handshake failure · Cloudflare 526 certificate validation failure

Once the certificate verifies on your machine, rerun the request from the application environment. Compare the reported IP with the exit you expect. Run a separate cURL proxy check or repeat the proxy test in Python Requests.

All proxy testing guides · Open the proxy tester