Skip to content

How to Use OpenSSL s_server for Local TLS Testing

DodaTech Updated 2026-06-24 2 min read

OpenSSL s_server creates a local TLS server for testing purposes. It is invaluable for verifying certificates and debugging handshake issues. This guide walks through the specific troubleshooting steps to diagnose and resolve local TLS testing issues using s_server.

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_server -accept 4433 -cert cert.pem -key key.pem

Wrong: Basic s_server without client verification

openssl s_server -accept 4433 -cert cert.pem -key key.pem -CAfile ca-chain.pem -Verify 1 -www

Right: s_server with client cert verification and HTTP debug page

Output

Using default temp DH parameters\nACCEPT\nTLSv1.3, ECDHE-RSA-AES256-GCM-SHA384\nClient certificate: CN=client.example.com

Prevention

To avoid future issues, follow these best practices:

  • Use -www to serve a simple HTTP status page for browser testing
  • Add -Verify 1 to request and verify client certificates
  • Use -CAfile to specify the CA chain for client certificate validation
  • Test different cipher suites with -cipher option
  • Use -tlsextdebug for detailed TLS extension logging

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 server

  1. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  2. Using return to exit a function early instead of wrapping a pure value in the monad
  3. Mixing let bindings with <- bindings in do notation, producing type errors

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

How do I test a client certificate with s_server?|||Run openssl s_server -accept 4433 -cert server.pem -key server.key -CAfile ca.pem -Verify 1 -verify_return_error. Then connect with curl --cert client.pem --key client.key.
Can s_server handle multiple concurrent connections? s_server handles one connection at a time by default. For load testing, use a proper web server.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro