openssl s_client opens a TLS connection and prints what the server presents. A handful of options cover most debugging: the target, the server name, the certificates sent, the protocol version, application protocol and STARTTLS. It is a test tool, so it behaves differently from a strict client.
Basic connection
openssl s_client -connect example.com:443 -servername example.com
The -connect option sets host and port. The -servername option sets the SNI value. Without it, SNI is taken from the connect argument if that looks like a DNS name. Setting it explicitly matters when you connect by IP address or test a virtual host behind a shared address.
See the certificates the server sends
openssl s_client -connect example.com:443 -servername example.com -showcerts
The -showcerts option displays the certificates in the order the server sent them. The documentation notes this is not a verified chain. It is useful for spotting a missing intermediate, a wrong order or a leaf from the wrong site.
Choose the protocol and ALPN
openssl s_client -connect example.com:443 -servername example.com -tls1_3 -alpn h2,http/1.1 -brief
-tls1_3selects TLS 1.3, which tests whether a server supports it.-alpnadvertises a comma separated list of application protocols, most preferred first.-briefprints a short summary of connection parameters.
Test mail servers with STARTTLS
openssl s_client -connect mail.example.com:25 -starttls smtp -servername mail.example.com
The -starttls smtp option sends the SMTP messages needed to upgrade to TLS. This is the quickest way to see what certificate a mail server presents. It pairs well with MTA-STS and STARTTLS downgrade protection.
Request OCSP status
openssl s_client -connect example.com:443 -servername example.com -status
The -status option requests an OCSP status response (stapling) and prints the server's response if one is sent. Note the CA changes described in OCSP is being retired.
Read the verification result carefully
The documentation says verification errors are displayed, but the handshake continues unless -verify_return_error is set. In other words, a connection that prints a certificate is not proof that a real client would accept it. Add verification options such as -verify to enable server certificate checking, and -verify_quiet to show only errors. Hostname matching has its own rules, described in how TLS checks the hostname.
A debugging order
- Confirm DNS returns the address you expect.
- Connect with the right
-servername. - Look at the certificates sent and their order.
- Force each protocol version you care about.
- Check hostname and expiry on the leaf.
Where Safeguard fits
Safeguard does not manage this layer of your infrastructure. It scans the dependencies and SBOMs of the software you ship, uses reachability analysis to show which vulnerable code paths are actually used, and can enforce policies and gates in CI. A free scan is at gold.safeguard.sh/scan.
Quick check
Why add -servername?
It sets the SNI value, so a server hosting several names can return the right certificate.
Does a printed certificate mean the connection is trusted?
No. By default s_client continues after verification errors, so check the reported verification result.
Sources
Last reviewed: 19 October 2026.