“wrong version number”: when TLS meets plain text

The name is misleading: it is not about an old TLS version. The client expected a TLS response and got something completely different, usually plain text.

What the error means

curl: (35) error:0A00010B:SSL routines::wrong version number
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1006)

Every TLS record starts with a type byte and the protocol version. If HTTP/1.1 400 Bad Request or 220 mail.example.com ESMTP comes back instead, OpenSSL reads those bytes as a version number and reports a wrong version. Older OpenSSL versions write ssl3_get_record:wrong version number.

The most common causes

  1. Wrong port. https://example.com:80 or a service that only speaks HTTP on 8080.
  2. STARTTLS port addressed with direct TLS. Ports 587 and 25 start in plain text and switch with STARTTLS. Setting smtps:// or “SSL/TLS” there gives this error. Direct TLS is on 465 (SMTP), 993 (IMAP) and 995 (POP3).
  3. Proxy configured with https://. Very common in corporate networks: HTTPS_PROXY=https://proxy:3128. Almost all proxies speak plain HTTP, even for HTTPS targets. Correct is HTTPS_PROXY=http://proxy:3128.
  4. nginx without ssl in listen. listen 443; instead of listen 443 ssl; serves plain text on port 443.
  5. Load balancer or ingress does not terminate TLS. The service behind it expects TLS but gets plain text, or the other way round.

Check

# Does the port answer in plain text? Then HTML comes back here
curl -v http://example.com:443/

# Mail server: STARTTLS instead of direct TLS
openssl s_client -connect mail.example.com:587 -starttls smtp -servername mail.example.com

# Which proxy is set?
env | grep -i _proxy

In the SSL check you choose the port; on 25, 587, 143 and 110 it uses STARTTLS automatically.

Fix

FAQ

Do I need to update OpenSSL?

Almost never. The error occurs because the other side does not speak TLS. Only if a server really only supports SSLv3 or TLS 1.0 do you get other messages such as “unsupported protocol”.

Why does it work in the browser but not with curl?

Browsers often take the system proxy settings with http://, curl reads HTTPS_PROXY from the environment. If that says https://, curl fails.

Which port for Thunderbird or Outlook?

Sending via 587 with STARTTLS or 465 with SSL/TLS, receiving via 993 with SSL/TLS. Port and encryption type must match.

Sources and documentation