$linuxjunkies
>

openssl-s_client(1)

OpenSSL TLS/SSL client for testing and debugging SSL/TLS connections to remote servers.

UbuntuDebianFedoraArch

Synopsis

openssl s_client [-connect host:port] [-servername name] [options]

Description

s_client is a versatile tool for establishing TLS/SSL connections to remote servers, displaying certificate details, and diagnosing connection issues. It acts as a simple SSL/TLS client that prints the certificate chain, cipher information, and allows you to send/receive data interactively or via pipes.

Common uses include testing HTTPS servers, verifying certificate validity, checking certificate expiration dates, validating certificate chains, and debugging TLS handshake problems.

Common options

FlagWhat it does
-connect host:portSpecify server and port to connect to (required unless stdin is used)
-servername nameSet SNI (Server Name Indication) hostname for TLS handshake
-showcertsDisplay the full certificate chain from the server
-cert fileClient certificate file (for mutual TLS authentication)
-key filePrivate key file for client certificate
-CAfile fileFile with trusted CA certificates for verification
-CApath directoryDirectory with CA certificates (for verification)
-quietSuppress connection state messages
-tls1_2Force TLS 1.2 protocol (also -tls1_3, -ssl3)
-cipher ciphersSpecify cipher suites to use (e.g., 'HIGH:!aNULL')
-starttls protocolUse STARTTLS (smtp, pop3, imap, ftp, xmpp, xmpp-server, etc.)

Examples

Connect to example.com on HTTPS and display certificate details

openssl s_client -connect example.com:443

Connect with SNI enabled (required for servers hosting multiple TLS certificates)

openssl s_client -connect example.com:443 -servername example.com

Extract certificate subject from a server without interactive mode

echo | openssl s_client -connect example.com:443 -showcerts 2>/dev/null | grep 'subject='

Check certificate expiration dates without interaction

openssl s_client -connect example.com:443 -servername example.com < /dev/null 2>&1 | openssl x509 -noout -dates

Test SMTP with STARTTLS on port 587

openssl s_client -connect mail.example.com:587 -starttls smtp

Connect using client certificate for mutual TLS (mTLS) authentication

openssl s_client -connect example.com:443 -cert client.crt -key client.key

Force TLS 1.3 and use only HIGH strength ciphers

openssl s_client -connect example.com:443 -tls1_3 -cipher 'HIGH'

Verify certificate against a custom CA bundle

openssl s_client -connect example.com:443 -CAfile /etc/ssl/certs/ca-bundle.crt

Related commands