How to Use OpenSSL s_client for TLS Debugging
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
Right
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
- Using
foldlinstead offoldl'causing stack overflow on large lists - Forgetting
deriving (Show, Eq)on custom data types needed for debugging - 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
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro