← Back to section · Software & Developer Tools
The Position of the Diagnostic Tools: s_client and s_server in the Troubleshooting Chain
s_client and s_server are the two most commonly used diagnostic subcommands in OpenSSL: one pretends to be a client and probes a server, the other stands up a test server locally. This article explains what each can prove — and what it cannot.
When TLS breaks, the OpenSSL subcommand most people reach for first is usually s_client. It is famous enough to be misused easily: some treat it as a connectivity test, others treat its output as a compliance conclusion. In fact, s_client and its partner s_server are diagnostic tools with precise roles — understanding what each can and cannot prove matters more than memorizing options. This article does not tabulate options; it explains positioning and the logic of use. Every option mentioned is a real, commonly used one.
s_client: A TLS Probe That Talks
s_client’s job is to initiate a real TLS connection to a designated server and then lay out the whole handshake and its conclusion for you: the certificate chain the peer presented, the negotiated protocol version and cipher suite, session parameters, and the return value of certificate verification. The question it answers is: “starting from the machine running it, with this set of parameters, what does the peer’s TLS configuration look like?”
A few common options correspond to the most frequent troubleshooting intentions. -connect designates the target host and port — the entry point; -servername sends SNI — in a world of pervasive virtual hosting, connecting without SNI may reach a completely different site, and most certificate mismatches originate here; -showcerts prints the entire certificate chain the peer sent, making classic faults like a missing intermediate certificate visible at a glance; -CAfile designates a trust root to test separately “with a different trust anchor, does verification pass”; -alpn specifies an ALPN list to reproduce protocol-negotiation issues such as HTTP/2; -tls1_3 or -tls1_2 constrains the protocol version to determine which generation the peer actually supports. After the handshake completes it keeps the connection open, so you can type an HTTP request by hand for the most primitive application-layer probing.
At the end of its output there is a line, Verify return code: 0 means certificate verification passed; a non-zero value corresponds to a specific verification failure reason (the meaning of a code can be looked up with errstr). That line is the first thing to read in s_client’s output.
s_server: A Local Control Group
s_server does the opposite: it starts a test TLS server on the local machine with a designated certificate and private key and waits for clients to connect. Its troubleshooting value is “separating variables”: when a service cannot be connected to or its certificate is rejected, use s_server to serve the same certificate locally, then connect with s_client or the real client — if it works, the certificate and key themselves are fine and the fault lies in the original server’s software configuration; if it fails, the problem is pinned to the certificate material.
It also carries a few test-oriented options: in -www mode it returns, for each connection, a simple page displaying the connection parameters, convenient for eyeballing negotiation results; -accept specifies the listening port; and -key and -cert designate the private key and certificate files separately. Using s_server as a production server, by contrast, is misuse: it has no design for concurrency, robustness, or security hardening — it is a workbench.
How to Read the Output: Conclusion First, Then the Process
s_client’s output is long, and beginners drown in the details easily; the correct reading order is fixed. First, the certificate-chain part: how many certificates the peer sent, in what order, and what each one’s subject and issuer are — an incomplete or misordered chain shows up here. Next, the handshake summary: which protocol version and cipher suite were negotiated, and whether they match expectations — for example, believing TLS 1.3 is enabled while 1.2 was actually negotiated points at the peer’s configuration or a middlebox. Finally, the verification verdict line (Verify return code), which adjudicates the whole chain’s validation; when it is non-zero, first classify the failure by the code’s meaning (expired, self-signed, incomplete chain, and so on), then go back to the chain part and find the corresponding level.
If only the conclusion is needed and not the full record, s_client in 3.x offers the -brief option, which prints a concise handshake summary suited to batch inspection scripts. Conversely, in difficult cases the full line-by-line output (including handshake message details) is where the value lies: it shows exactly where the handshake stalls — no response after the ClientHello, or a break right after the certificate arrives — information no “success/failure”-style probe can give. Fix the reading order, and s_client turns from “a pile of log” into “a diagnostic report.”
What This Pair of Tools Cannot Prove
First, one successful handshake proves only that this one network path, with this one set of parameters, worked at this one moment. Behaviors such as client-certificate authentication, a specific ALPN, session resumption, and mutual authentication must each be reproduced with the corresponding options; conclusions from a default connection cannot be extrapolated. Second, s_client’s verification uses OpenSSL’s own validation logic and the local trust store, and may differ from the result in a particular browser or a particular language runtime — it can prove “whether the certificate chain itself is complete and anchored to a given trust root,” but it is no substitute for testing the target client. Third, it cannot see the application layer: errors in the business protocol after the handshake require other tools to chase further.
Their Place in the Troubleshooting Chain
A sensible order is: first probe the peer with s_client from the same position as the failing machine, obtaining the certificate chain and the verification code; then run the control experiment locally with s_server, separating certificate problems from server problems; finally, verify the fix with the real client and the real server. Each covers one segment, and none of their conclusions may overreach its boundary. Remember the positioning clearly, and these two small tools will save more troubleshooting time than their option tables are long.
It is also worth clarifying its relation to everyday tools: curl’s verbose output and browsers’ certificate viewers also present TLS information; their advantage is closeness to the real client, their disadvantage is that they mostly show processed conclusions and their behavior is affected by their own implementations and caches. s_client’s value is that it “takes no position”: it does not redirect, does not consume caches, does not decide for you — it simply lays out the raw facts of one handshake. In troubleshooting, pin the facts down with it first, then verify the actual user-side experience with the real client; do not reverse the order — looking at the browser first and then guessing at the lower layers is the most common detour in TLS troubleshooting.
Tags: OpenSSLTLSDiagnosticss_client