The Basic Command
openssl s_client -connect example.com:443 -servername example.com </dev/null-connect takes the host and port. -servername sends the name in the SNI extension, which tells a server with several sites which certificate to present. Current OpenSSL releases send SNI from the -connect host on their own when it is a DNS name, but writing it out is clearer, and it is required when you connect by IP address:
openssl s_client -connect 203.0.113.10:443 -servername example.com </dev/nullThe </dev/null at the end gives s_Q on a line of its own.
Reading the Output
- Certificate chain: one numbered entry per certificate sent, with
s:for the subject andi:for the issuer. Entry 0 is your site's certificate. - Server certificate: the site's certificate in PEM form.
- Protocol and cipher: the TLS version and cipher suite that were agreed.
- Verify return code: near the end.
0 (ok)means the chain is complete and trusted by the system's store of authorities.
Add -brief for a short summary of the protocol, cipher, and verification result.
Common Verify Return Codes
| Code | Meaning |
|---|---|
| 0 | Verified |
| 10 | Certificate has expired |
| 18 | Self-signed certificate |
| 19 | Self-signed root in the chain |
| 20 | Local issuer not found |
| 21 | First certificate not verifiable |
Codes 20 and 21 on a site that works in some browsers usually mean the server sends its certificate without the intermediate. In Nginx, point ssl_ at the full chain file, for Let's Encrypt fullchain.pem, not cert.pem. s_-verify_ to make it abort instead.
Show the Whole Chain
openssl s_client -connect example.com:443 -servername example.com -showcerts </dev/null-showcerts prints every certificate the server sends, not only the first. To read the dates and names of the site's own certificate, pipe the output into openssl x509:
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates -ext subjectAltNameTest a Specific TLS Version
openssl s_client -connect example.com:443 -servername example.com -tls1_2 </dev/null
openssl s_client -connect example.com:443 -servername example.com -tls1_3 </dev/nullEach command offers only that version. A successful handshake shows the protocol and cipher; a server that refuses the version ends with a handshake failure or a protocol version alert. Test both on any public site: current browsers use TLS 1.2 and 1.3 only. This is the first test for ERR_
Test Mail Servers with STARTTLS
Mail protocols start in plain text and switch to TLS with a STARTTLS command. s_
openssl s_client -connect mail.example.com:587 -starttls smtp -servername mail.example.com </dev/null
openssl s_client -connect mail.example.com:25 -starttls smtp </dev/nullOther values include imap, pop3, ftp, ldap, mysql, and postgres. Ports with TLS from the first byte, such as 465, 993, and 995, need no -starttls.
Other Useful Options
| Option | Use |
|---|---|
-alpn h2 | Asks for HTTP/2 |
-CAfile ca.crt | Trusts your own CA |
-cert, -key | Client certificate |
-4, -6 | IPv4 or IPv6 only |
Testing IPv4 and IPv6 separately finds servers where one address family presents an old certificate. If the connection does not open at all, check the port first, as in the nc command.
Updated:
Linux VPS with Full Root Access
MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.
More Guides
No Limits on Service or Support
You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

- 100% customer satisfaction goal
- Our own hardware
- 24/7 ticket and email support
- 4 countries with locations