Check chain, host name and expiry
Choose what you want to know and enter the host name the way visitors use it (with or without www). -servername makes the server present the certificate for exactly that name.
Only inserted into the commands in your browser.
Verify the chain · openssl · Linux, macOS
The chain as the server sends it: s: is the subject, i: the issuer. Each level's i: must be the next level's s:. The last line is the verdict; 0 (ok) means the chain leads without gaps to a trusted root.
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | grep -E "^ [0-9]+ s:|^ i:|Verify return code" 0 s:CN=example.com
i:C=US, O=Example Trust, CN=Example Issuing CA 1
1 s:C=US, O=Example Trust, CN=Example Issuing CA 1
i:C=US, O=Example Trust, CN=Example Root CA
Verify return code: 0 (ok)Verify the chain · curl · Linux, macOS
curl verifies chain and host name in one go and sums up: "SSL certificate verify ok." or "SSL certificate problem: …" with the reason. It does not print the chain itself.
curl -svI https://example.com 2>&1 | grep -E "subject:|issuer:|expire date|subjectAltName|SSL certificate"* subject: CN=example.com
* expire date: Dec 25 22:56:35 2026 GMT
* subjectAltName: host "example.com" matched cert's "example.com"
* issuer: C=US; O=Example Trust; CN=Example Issuing CA 1
* SSL certificate verify ok.Chain and host name · openssl · Linux, macOS
Without -verify_hostname s_client checks the chain only. With the option it also matters whether the certificate covers this name; a wrong name gives "62 (hostname mismatch)". OpenSSL only, not LibreSSL.
openssl s_client -connect example.com:443 -servername example.com -verify_hostname example.com </dev/null 2>/dev/null | grep VerifVerification: OK
Verified peername: example.com
Verify return code: 0 (ok)Chain and host name · curl · Linux, macOS
curl only connects when chain and name are valid. "OK" therefore appears only for a valid certificate; otherwise curl exits with error code 60.
curl -sI https://example.com -o /dev/null && echo OKOKExpiry date · openssl · Linux, macOS
-enddate prints the expiry date, -checkend tests whether it falls within the next 2592000 seconds (30 days) and sets the exit code for scripts. LibreSSL prints only the date; the exit code is still right.
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | openssl x509 -noout -enddate -checkend 2592000notAfter=Dec 25 22:56:35 2026 GMT
Certificate will not expireExpiry date · curl · Linux, macOS
The server certificate's expiry date taken from curl's verbose output.
curl -svI https://example.com 2>&1 | grep "expire date"* expire date: Dec 25 22:56:35 2026 GMTA complete chain consists of the server certificate (level 0) and every intermediate. The server does not need to send the root; it lives in the client's trust store.
The verify return codes
The number on the last line says where verification failed. These are the ones you meet in practice:
- 0 (ok): the chain is valid. Without -verify_hostname that says nothing about the host name.
- 20 (unable to get local issuer certificate): the issuer of one certificate in the chain is missing. Nearly always the server does not send the intermediate.
- 21 (unable to verify the first certificate): the consequence of 20 right at the server certificate. The server sends only its own certificate.
- 10 (certificate has expired): a certificate in the chain is past its date. Usually the server certificate, occasionally a stale intermediate left in the configuration.
- 18 (self-signed certificate): the server certificate is self-signed; there is no chain.
- 19 (self-signed certificate in certificate chain): the chain ends at a root your system does not trust, such as a company CA or a TLS-inspecting proxy on the network.
- 62 (hostname mismatch): only with -verify_hostname. The chain is fine but the certificate does not cover this name.
For 20 and 21 the fix is on the server: configure the full chain instead of the single certificate, with Let's Encrypt the file fullchain.pem rather than cert.pem. The order is server certificate first, then the intermediates.
Verify certificate files before deploying them
When certificate and chain arrive as files, check them before they go onto the server. -untrusted passes the intermediates, -show_chain prints the chain that was built.
$ openssl verify -show_chain -untrusted chain.pem cert.pem
cert.pem: OK
Chain:
depth=0: CN=example.com (untrusted)
depth=1: C=US, O=Example Trust, CN=Example Issuing CA 1 (untrusted)
depth=2: C=US, O=Example Trust, CN=Example Root CA
$ openssl verify cert.pem
CN=example.com
error 20 at 0 depth lookup: unable to get local issuer certificate
error cert.pem: verification failed"(untrusted)" only means the certificate came from the file you passed rather than the trust store. The second call, without the chain, shows exactly the error clients see when the server omits the intermediate. grep -c "BEGIN CERTIFICATE" chain.pem counts the certificates in a file.
Careful with the openssl on macOS
/usr/bin/openssl on macOS is LibreSSL. Tested against a server with a missing intermediate, LibreSSL 3.3.6 did print "verify error:num=20" and "num=21", but finished with "Verify return code: 0 (ok)". Read only the last line and you will think the chain is valid. OpenSSL 3 correctly reported 21 for the same server.
curl disagrees across systems too: the curl on macOS said "SSL certificate verify ok." for that server, curl on Debian said "unable to get local issuer certificate". For chain checks rely on a current OpenSSL (via Homebrew: brew install openssl) or on a test from Linux, and watch for "verify error" lines further up in the output.
- Names: OpenSSL 3.2 and later prints "s:CN=example.com", older versions such as 1.1.1 and 3.0 "s:CN = example.com" with spaces, LibreSSL "s:/CN=example.com".
- LibreSSL does not know -verify_hostname or -brief ("unknown option").
- With OpenSSL, -verify_return_error aborts the handshake with an error exit code as soon as verification fails, so a script can read the result from the exit status.
- openssl x509 -ext subjectAltName exists only in OpenSSL; on LibreSSL use -text.
Checking without a terminal
The SSL checker connects with SNI, verifies the chain against the common root stores and shows issuer, validity, alternative names and the negotiated protocol version, for mail server ports as well if you like. More openssl commands for reading certificates are in the guide "Check an SSL certificate with openssl".