Network tools · Network tools

OpenSSL Commands to Check TLS Certificates and Chains

A server can complete a TLS handshake while presenting a certificate that the client should not trust. Test the requested hostname and the certificate chain explicitly. When a load balancer hosts several sites, also send the correct Server Name Indication, or SNI, so the server selects the intended certificate.

Scope: OpenSSL 3.x; POSIX shell examples. Network commands initiate a TLS connection; local x509 commands inspect a file.

Check a live HTTPS endpoint #

Check a live HTTPS endpoint
Network tools · Local shell; platform and privileges as described below

Active test

Replace these example values: example.com.

openssl s_client -connect example.com:443 -servername example.com \
  -verify_hostname example.com -verify_return_error -brief </dev/null

For a particular backend, keep the public hostname in both name options and replace only the connection address:

Check a live HTTPS endpoint
Network tools · Local shell; platform and privileges as described below

Active test

Replace these example values: 192.0.2.20, example.com.

openssl s_client -connect 192.0.2.20:443 -servername example.com \
  -verify_hostname example.com -verify_return_error -brief </dev/null

This separates address selection from identity checking. The verification result depends on the trust anchors available to that OpenSSL installation. For a private PKI, supply the approved CA file with -CAfile company-ca.pem; do not replace verification with a blanket trust bypass.

Inspect a certificate file #

Inspect a certificate file
Network tools · Local shell; platform and privileges as described below

Read-only

Replace these example values: server.pem.

openssl x509 -in server.pem -noout -subject -issuer -dates
Read-only

Replace these example values: server.pem.

openssl x509 -in server.pem -noout -ext subjectAltName
Read-only

Replace these example values: server.pem.

openssl x509 -in server.pem -noout -fingerprint -sha256
Read-only

Replace these example values: server.pem.

openssl x509 -in server.pem -noout -checkend 604800

These commands inspect the subject, issuer, validity period, names and fingerprint. The final command checks whether the certificate expires within seven days. It is an expiry check, not a full trust or hostname check. A currently unexpired certificate can still have the wrong name or an untrusted issuer.

Examine what the server sends #

Examine what the server sends
Network tools · Local shell; platform and privileges as described below

Active test

Replace these example values: example.com.

openssl s_client -connect example.com:443 -servername example.com \
  -showcerts </dev/null

The displayed list is the chain material supplied by the server, not a declaration that the chain is trusted. Compare the leaf's issuer with the supplied intermediates and the client's trust configuration. Browser success does not guarantee that a different client has the same trust store or chain-building behavior.

Common interpretation mistakes #

Do not treat a printed certificate as proof of successful validation. The strict test above uses -verify_return_error so verification errors stop the handshake rather than merely being reported. Check the system clock when validity dates appear wrong. If only one backend returns a different fingerprint, investigate deployment consistency before changing DNS or clients. Finally, a valid TLS identity does not prove the HTTP application is healthy; continue with an HTTP request after certificate verification succeeds.

Sources

Documentation reviewed: 8 October 2026