🔍
blog.cat.ssl

Checking an SSL certificate with OpenSSL: the commands you actually need

19.11.2026
← All articles

The padlock in a browser tells you very little. When a site works on one computer but fails on another, a mobile app cannot connect or a mail client complains about the certificate, you need the exact cause. OpenSSL is the most reliable tool for that. It ships with most Linux and macOS systems and comes with Git for Windows or WSL on Windows.

Connect and look at the certificate

s_client connects over TLS just like a browser. Always pass -servername: it sends SNI, and on shared hosting with hundreds of sites per IP the server may otherwise return a different site's certificate.

openssl s_client -connect example.uz:443 -servername example.uz </dev/null

Who it was issued to and when it expires

Pipe the output into x509 to see the subject, issuer and validity dates; notAfter is the expiry in UTC. An unexpected issuer, such as a hosting panel's default name, means the wrong certificate is installed.

echo | openssl s_client -connect example.uz:443 -servername example.uz 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates

# subject=CN = example.uz
# issuer=C = US, O = Let's Encrypt, CN = R11
# notBefore=...
# notAfter=...

The SAN field lists the names the certificate covers. If a Tashkent dental clinic's site works on example.uz but fails on www.example.uz, the second name is usually missing from SAN. This option needs OpenSSL 1.1.1 or newer.

echo | openssl s_client -connect example.uz:443 -servername example.uz 2>/dev/null \
  | openssl x509 -noout -ext subjectAltName

Is the chain complete?

-showcerts prints every certificate the server sends. For each, s: is the subject and i: the issuer; in a correct chain the first issuer matches the second subject. Only one certificate means the intermediate is missing.

echo | openssl s_client -connect example.uz:443 -servername example.uz -showcerts 2>/dev/null \
  | grep -E 's:|i:'

echo | openssl s_client -connect example.uz:443 -servername example.uz 2>/dev/null \
  | grep 'Verify return code'
# Verify return code: 0 (ok)

0 (ok) is what you want. Code 20 usually means a missing intermediate, 10 an expired certificate, and 18 or 19 a self-signed one. Verification relies on your machine's trust store, so a very old system may not know a newer CA.

Reading a certificate file

Check a certificate before installing it. -checkend tests whether it expires within the given number of seconds and reports via exit code, which is handy in scripts; 1209600 seconds is 14 days.

openssl x509 -in certificate.crt -noout -text
openssl x509 -in certificate.crt -noout -enddate
openssl x509 -in certificate.crt -noout -checkend 1209600 \
  && echo "more than 14 days left" || echo "expires within 14 days"

Do the certificate and private key match?

Using a key from a different request is a classic mistake: Nginx refuses to start and panels reject the upload. Compare the public key inside the certificate with the one derived from the private key; identical hashes mean a match, for both RSA and ECDSA. You can also verify the chain file offline.

openssl x509 -in certificate.crt -noout -pubkey | openssl sha256
openssl pkey -in private.key -pubout | openssl sha256
openssl verify -CAfile chain.crt certificate.crt
# certificate.crt: OK

Mail servers

Mail clients are stricter than browsers. Ports 465 and 993 are encrypted from the start, while 587 upgrades with STARTTLS, so it needs -starttls. The certificate name must match the server name configured in the mail client.

openssl s_client -connect mail.example.uz:465 -servername mail.example.uz
openssl s_client -connect mail.example.uz:993 -servername mail.example.uz
openssl s_client -starttls smtp -connect mail.example.uz:587 -servername mail.example.uz

Protocol versions

Force a single TLS version to see what the server supports. TLS 1.2 and 1.3 should be enabled; 1.0 and 1.1 should be off.

openssl s_client -connect example.uz:443 -servername example.uz -tls1_2 </dev/null
openssl s_client -connect example.uz:443 -servername example.uz -tls1_3 </dev/null

Acting on the results

Expired: renew and reload the web server. Missing SAN name: reissue the certificate covering every name. Incomplete chain: install the full chain file. On sayt.uz hosting, Let's Encrypt certificates are issued through the panel with the chain added automatically, so these issues mostly appear with manually uploaded commercial certificates. If the output is hard to read, send it to support; it speeds up diagnosis considerably.

Related articles

🌐 One SSL certificate for both www and non-www: setting it up correctly ⚛️ Post-Quantum Encryption (ML-KEM): What Is Changing in TLS 🧭 Hundreds of domains on one server: how SNI keeps SSL from mixing up 🚫 Disabling TLS 1.0 and 1.1: Why It Matters and How to Do It
🌐 Language
🇺🇿 O'zbek 🇺🇿 Ўзбек 🇷🇺 Русский 🇬🇧 English ✓