Use this repeatable workflow to inspect an SSL/TLS certificate with OpenSSL and browser tools, confirm its expiry date, issuer, hostname coverage, chain, and server configuration before a launch, renewal, migration, or incident review.
Overview
An HTTPS connection can fail even when a certificate file exists on the server. The certificate may be expired, issued for a different hostname, missing an intermediate certificate, or installed on the wrong virtual host. Inspection helps separate those problems from unrelated DNS, firewall, application, or protocol issues.
There are two useful perspectives:
- Browser inspection shows what a normal visitor receives and whether the browser accepts it.
- OpenSSL inspection exposes certificate fields, the presented chain, negotiated TLS details, and validation behavior from a command line.
Always test the hostname that users actually visit. A server can present different certificates for different domains, so include the -servername option when using OpenSSL against a shared IP address.
Quick command reference
| Purpose | Command |
|---|---|
| Show the live certificate dates and identity | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -dates -issuer -subject |
| Check expiry only | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -enddate |
| Display all certificate fields | openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -text |
| Show the presented chain | openssl s_client -connect example.com:443 -servername example.com -showcerts |
| Test certificate verification | openssl s_client -connect example.com:443 -servername example.com -verify_return_error |
| Test a specific hostname | openssl s_client -connect example.com:443 -servername example.com -verify_hostname example.com |
OpenSSL output can vary by version and operating system. If a hostname-verification option is unavailable in the installed version, use the browser check or inspect the certificate's Subject Alternative Name field and validate the chain separately.
Checklist by scenario
Before launching a domain
- Confirm DNS resolves the intended hostname to the intended service. Check both the apex domain and any
www, API, mail, or administrative subdomains that will use HTTPS. - Run the live OpenSSL command with the exact hostname and
-servername. - Check
notBeforeandnotAfter. The current time must fall within that range. - Read the Subject Alternative Name extension. Modern hostname checks use the names listed there, not merely the older Common Name field.
- Confirm the certificate chain is complete from the server to a trusted root through the appropriate intermediate certificate.
- Open the site in a browser and inspect the certificate from the address-bar security controls. Browser labels differ, but certificate details normally include the subject, issuer, validity period, and name coverage.
When checking an expiry date
The most direct expiry command is:
openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -enddate
The result usually resembles notAfter=.... This checks the certificate currently served over the network, which is more useful than checking a certificate file that may no longer be loaded by the web server. If the site is behind a proxy, load balancer, CDN, or hosting control panel, inspect the public endpoint as well as the origin server.
When investigating the issuer or hostname
Use:
openssl s_client -connect example.com:443 -servername example.com 2>/dev/null | openssl x509 -noout -issuer -subject -ext subjectAltName
The issuer identifies the certificate authority that signed the certificate. It is not the same as the website owner. The subject identifies the certificate's primary identity, while the Subject Alternative Name list determines which hostnames the certificate is intended to cover. A certificate for example.com does not automatically cover every subdomain, and a wildcard such as *.example.com has specific scope and does not ordinarily cover the apex domain itself.
When inspecting the certificate chain
Run:
openssl s_client -connect example.com:443 -servername example.com -showcerts
This prints the certificates presented by the server. The first certificate is normally the site's leaf certificate; following certificates are typically intermediates. The server should present the chain clients need, but it should not normally send a root certificate. A chain that works in one browser and fails in another can indicate that the server is relying on a cached or locally available intermediate instead of presenting the correct chain.
For a validation-oriented test, add -verify_return_error. A successful connection alone is not proof that every client will build a trusted chain. OpenSSL uses the trust store available on the machine where the command runs, so repeat the test from an environment representative of your users when possible.
When a browser reports a warning
Open the browser's certificate or connection details panel and compare four values: hostname, expiration, issuer, and chain. Also note the browser's exact warning. A hostname mismatch points toward the certificate names or the requested hostname. An expired-certificate warning points toward issuance, renewal, or a server that is still serving an old file. A trust or chain warning points toward the intermediate certificates or the client's trust store.
What to double-check
- Server Name Indication: Include
-servername example.com. Without it, a shared server may return a default certificate for another site. - All endpoints: Test HTTP-to-HTTPS redirects, the apex domain,
www, IPv4 and IPv6 where applicable, and any separate load balancer or origin address. - Certificate dates: Check the live endpoint after installation and again after an automated renewal. A renewed file does not help if the service was not reloaded.
- Subject Alternative Names: Verify every hostname used by the application, including API and staging names if they are publicly exposed.
- Chain order: Confirm the server sends the leaf followed by the required intermediate certificates. Do not assume a browser cache represents a clean client.
- Private key pairing: If you are inspecting a local certificate before deployment, compare its public key with the configured private key. The live endpoint remains the final authority for what visitors receive.
- Protocol and cipher context: Certificate inspection does not replace a TLS configuration review. A valid certificate can coexist with an incorrect protocol policy, redirect loop, or weak server configuration.
For Let’s Encrypt deployments, pair this inspection with a renewal test and service-reload check. The Let’s Encrypt setup guide covers issuance, installation, and automated renewal. If validation fails before a certificate is issued, see the guide to common certificate errors and validation failures.
Common mistakes
- Checking the certificate file instead of the public service: The file on disk may be current while the web server still uses an older certificate.
- Omitting SNI: This is one of the most common reasons OpenSSL appears to show the wrong certificate.
- Checking only the Common Name: Review Subject Alternative Names for hostname coverage.
- Confusing issuer and owner: The issuer is the signing certificate authority; it does not identify who operates the website.
- Treating
verify return:1as a complete audit: Verification depends on the local trust store and does not by itself prove hostname coverage or correct application routing. - Ignoring redirects and alternate names: Visitors may reach a different endpoint than the one tested manually.
- Copying a command without replacing the hostname: Substitute the real domain in both
-connectand-servername.
When to revisit
Make certificate inspection part of a recurring operational checklist rather than a one-time troubleshooting task. Run it before a new domain goes live, after changing DNS or hosting, immediately after certificate renewal, and after replacing a reverse proxy, load balancer, CDN, Nginx, Apache, or control-panel configuration.
A monthly audit is a practical baseline for sites that cannot afford an unexpected HTTPS outage. Record the hostname tested, expiry date, issuer, SAN coverage, chain result, and the machine or service that answered. Revisit the commands when your operating system, OpenSSL version, browser, deployment tooling, or TLS termination point changes. During an incident, save the full OpenSSL output and the browser warning before making changes; that evidence can reveal whether the problem is certificate selection, chain delivery, DNS, or application routing.
For a broader deployment review, use the secure HTTPS setup checklist for a new VPS. If certificates are managed by a hosting panel or Kubernetes, also verify the platform's renewal and reload behavior rather than relying only on a successful issuance log.
Action checklist: test the public hostname with SNI, record the expiry date, inspect the SAN list, review the issuer and chain, confirm the browser accepts the result, and repeat the test after the next configuration or certificate change.