Skip to content

How to Use OpenSSL s_client for TLS Debugging

DodaTech Updated 2026-06-24 2 min read

OpenSSL s_client is a powerful diagnostic tool for testing and debugging TLS connections. It provides detailed information about handshake parameters and certificates. This guide walks through the specific troubleshooting steps to diagnose and resolve TLS connection issues using s_client.

Before You Begin

Before you begin, be sure to have the following in place:

  • A Linux server with the relevant software installed
  • Access to the command line interface
  • Appropriate permissions (root or sudo)

Quick Fix

Wrong

openssl s_client -connect example.com:443

Wrong: Basic s_client without debugging flags

openssl s_client -connect example.com:443 -servername example.com -showcerts -tlsextdebug -state

Right: Extended s_client with certificate display and state tracing

Output

CONNECTED(00000003)\nSSL_connect:before/connect initialization\nSSL_connect:SSLv3/TLS write client hello\nSSL_connect:SSLv3/TLS read server hello\ndepth=2 CN=ISRG Root X1\nverify return:1

Prevention

To avoid future issues, follow these best practices:

  • Use -servername to set the SNI hostname correctly
  • Add -showcerts to display the full certificate chain sent by the server
  • Use -tlsextdebug for TLS extension debugging information
  • Add -state to see each stage of the SSL handshake process
  • Use -CAfile /path/to/ca-bundle.crt to test against a specific trust store

DodaTech Tools

For further assistance with any of the above issues, consider using DodaTech consulting services or DodaTech tutorials for more in-depth guidance.

Common Mistakes with s client

  1. Using foldl instead of foldl' causing stack overflow on large lists
  2. Forgetting deriving (Show, Eq) on custom data types needed for debugging
  3. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable

These mistakes appear frequently in real-world OPENSSL code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

What is the difference between s_client and s_server?|||s_client connects to a TLS server as a client -- useful for testing remote servers. s_server starts a TLS server locally -- useful for testing client configurations.
How do I check the SSL certificate chain with s_client? Run openssl s_client -connect example.com:443 -showcerts 2>/dev/null. Each certificate is displayed between its BEGIN/END markers.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro