Skip to content
MtrXTools

The SSL connection could not be established, see inner exception.

.NET could not complete the TLS handshake

Seen in .NET HttpClient (HttpRequestException), ASP.NET Core, PowerShell 7

HttpClient opened the connection but TLS failed; the inner exception gives the actual reason.

Common causes

  • The server certificate is untrusted, expired or for another name (inner: "The remote certificate is invalid...").
  • No TLS version or cipher in common with the server.
  • The connection was closed during the handshake by a proxy or firewall (inner: "Received an unexpected EOF or 0 bytes from the transport stream").

How to fix it

  1. Log the full exception including InnerException to see the real cause.
  2. On Linux containers, install and update ca-certificates.
  3. Check the certificate and TLS versions the server offers.
  4. Returning true from ServerCertificateCustomValidationCallback hides the problem and is not a fix.
Check the certificate

Got a different message? Paste it into the error explainer.

Related errors

All 32 Languages & runtimes errors