Bug Days
Developer guide

How to Check a TLS Certificate Chain, Expiry, SAN, and SNI on Any Port

Inspect the certificate chain a live HTTPS, Kafka SSL, LDAPS, SMTPS, IMAPS, or raw TLS service presents; diagnose expiry, SAN mismatch, SNI, trust, and missing intermediates.

· Updated 9 minute read TLS certificates and service diagnostics
TLS certificate chain checker reporting expiry, SAN hostname match, SNI, trust, and every certificate presented by a service

A certificate file can be perfectly valid while the service still presents an expired leaf, omits an intermediate, or selects the wrong certificate for a client’s SNI name. The reliable starting point is the live TLS handshake from the network where the service is used.

Check three separate claims: the certificate is within its validity window, its SAN covers the name the client verifies, and the presented chain reaches a root trusted by that client environment.

Inspect the live certificate chain, not only port 443

TLS protects more than HTTPS. Kafka brokers, LDAP directories, mail servers, databases, and custom TCP protocols can begin a TLS handshake immediately on their configured port. Enter the connection host, port, and optional SNI name in the TLS certificate chain checker.

Service exampleCommon direct-TLS portWhat to verify
HTTPS443Public hostname, full chain, expiry, ALPN
Kafka SSL9093 is common, but configurableBroker hostname verification and every advertised listener
LDAPS636Directory hostname, private CA trust, intermediate chain
SMTPS465Mail service name and server-auth usage
IMAPS993Mail hostname, expiry, and client trust path

Ports such as SMTP 25/587, IMAP 143, LDAP 389, and PostgreSQL 5432 commonly negotiate STARTTLS or a protocol-specific upgrade before the TLS handshake. A raw TLS checker does not perform those application commands; use a protocol-aware client when TLS does not start immediately.

Connection host and SNI name are not always the same

A client may connect to 10.20.4.8:9093 but verify broker-1.example.internal. SNI tells a server which DNS identity the client wants and is especially important when one address hosts multiple certificates.

# Connect to an explicit address while sending a DNS SNI name
openssl s_client \
  -connect 10.20.4.8:9093 \
  -servername broker-1.example.internal \
  -verify_hostname broker-1.example.internal \
  -verify_return_error -showcerts

-servername selects the SNI name; -verify_hostname checks the certificate against it. They are separate controls. -verify_return_error makes verification failures abort instead of letting s_client continue as a diagnostic convenience. For a private CA, add -CAfile organization-root.pem with the trust anchor your application is supposed to trust.

If the client genuinely verifies an IP address, that address must appear as an IP Subject Alternative Name. A DNS SAN containing the textual IP is not equivalent. Likewise, a PTR hostname discovered from reverse DNS is a clue, not automatic permission to substitute a different identity.

# Verify an IP identity, without sending a DNS SNI name
openssl s_client \
  -connect 10.20.4.8:9093 \
  -noservername -verify_ip 10.20.4.8 \
  -verify_return_error -showcerts

A server that requires SNI may reject the handshake before presenting any certificate. In that case there is no certificate to label “SAN mismatch.” Retry with the DNS identity the application actually uses to inspect the presented chain, while keeping clear that this is a different handshake.

Check LDAPS, SMTP, and IMAP with the right handshake

For direct TLS, change the connection port without adding an application-level upgrade. These examples verify the DNS name as well as requesting the chain:

openssl s_client -connect directory.example.com:636 \
  -servername directory.example.com -verify_hostname directory.example.com \
  -verify_return_error -showcerts

openssl s_client -connect mail.example.com:993 \
  -servername mail.example.com -verify_hostname mail.example.com \
  -verify_return_error -showcerts

For SMTP on port 587, the client must speak SMTP before upgrading. OpenSSL supports that negotiation; the Bug Days direct-TLS checker does not:

openssl s_client -starttls smtp -connect mail.example.com:587 \
  -servername mail.example.com -verify_hostname mail.example.com \
  -verify_return_error -showcerts

Use the matching -starttls imap or -starttls ldap mode for those protocols on their upgrade ports. Port numbers are conventions, not proof of configuration. Check the service’s listener settings and the OpenSSL s_client reference.

Check SANs, not a Common Name fallback

Modern hostname verification uses Subject Alternative Names. For a DNS name, an exact SAN is simplest. A wildcard such as *.example.com covers one leftmost label such as api.example.com; it does not cover example.com or v2.api.example.com.

  • DNS:api.example.com matches that hostname.
  • DNS:*.example.com matches api.example.com.
  • DNS:*.example.com does not match deep.api.example.com.
  • IP:10.20.4.8 can match a client that verifies that IP directly.

The checker uses DNS and IP SANs for identity matching and does not fall back to Common Name. These are separate identity types in RFC 9525. You can run the same SAN check against a pasted certificate without connecting to a service.

Check expiry across the entire chain

The leaf’s expiration date gets the most attention, but an expired intermediate can also break validation. Record the not-before and not-after dates for every presented certificate. Alert thresholds often begin at 30 days, but the right renewal margin depends on automation, change windows, and how widely a certificate is deployed.

A “not yet valid” result can indicate a newly issued certificate deployed too early or a bad system clock. Treat those causes separately.

Save each PEM certificate block from -showcerts as a separate file and inspect it. The following command examines one certificate, not every certificate in a concatenated bundle:

openssl x509 -in leaf.pem -noout -subject -issuer -dates \
  -ext subjectAltName -fingerprint -sha256

# Exit status 0 means this certificate does not expire within 30 days.
openssl x509 -in leaf.pem -noout -checkend 2592000

Repeat the expiry check for each intermediate. -checkend alone does not validate hostname coverage, signatures, trust, revocation, or the not-before date. The x509 reference documents the individual checks.

Recognize an incomplete or misordered chain

Servers normally present the leaf followed by intermediate certificates. They usually omit the root because clients already carry trust anchors. The issuer of certificate 1 should match the subject of certificate 2, and so on.

  • One leaf and unknown issuer: a missing intermediate is a strong possibility.
  • Issuer does not match the next subject: the chain may be misordered or unrelated certificates may have been bundled.
  • Root included: usually unnecessary, though not automatically the cause of failure.
  • Private CA: the chain may be correct but absent from the device trust store.

Matching issuer and subject names is a useful structural hint, not cryptographic proof: different CA certificates can share a name. Actual path validation checks signatures, constraints, usage, time, and an accepted trust anchor. Likewise, -showcerts displays the chain sent by the server, not a verified chain reconstructed by the client.

The report now checks signatures against supplied issuer candidates, even when a bundle is out of order. “Issuer not supplied” means the signature is unchecked, not automatically broken; leaving out a root is normal for many servers. An unsupported browser algorithm is also shown as unchecked, never as a verification pass.

Separate chain trust from service identity

A certificate can chain to a trusted root and still fail because the requested hostname is missing from SAN. It can cover the right hostname and still fail because an intermediate is absent. It can pass both checks and still be rejected by an application using a different trust store, Java runtime, container image, or certificate policy.

The Bug Days report captures the server-presented chain even when the trust pass fails, then shows the device trust result beside independent SAN and expiry analysis. Exporting the full chain table makes those separate findings easier to hand off.

Kafka TLS troubleshooting checklist

  1. Inspect every broker address clients receive from advertised.listeners, not only the bootstrap address.
  2. Use the same DNS name as the client’s endpoint-identification setting.
  3. If connecting by IP, provide the intended broker DNS name as SNI when that reflects the real client configuration.
  4. Confirm the leaf SAN covers each advertised broker name.
  5. Confirm every broker presents the required intermediate certificates.
  6. Compare the trust result with the actual JVM or application trust store when they differ from the operating system.

Export evidence another engineer can reproduce

A useful certificate incident report includes the connection target, port, SNI name, peer address, TLS version, cipher suite, presented chain order, expiry dates, SAN result, trust error, and SHA-256 fingerprints. Share a Bug Days snapshot when the public certificate data is suitable for sharing, or export CSV, Excel, JSON, PEM, and a printable PDF for a ticket.

Try it without a server: open the certificate inspector, choose Sample in the pasted-certificate view, and inspect its SANs and validity dates. Use the prominent Share action for a reproducible certificate example. A pasted certificate can demonstrate its fields; it cannot prove which chain a live server presented or which trust store a teammate uses.

For a live check, start the local bridge and connect from the network where the problem occurs, including a VPN if needed. If a service requires a client certificate, this checker cannot complete an authenticated mTLS investigation. Use the application’s approved client identity with a suitable TLS client; a server certificate alone says nothing about whether that client will be authorized.

Scope: the checker diagnoses direct TLS handshakes. It does not perform STARTTLS negotiation, client-certificate authentication, revocation checks, or Certificate Transparency monitoring.

Continue reading