JsonMind
Security & Authentication12 min readUpdated Nov 17, 2026

TLS Certificate Verification: Chain of Trust, SAN, Revocation, and Pinning

Verify TLS certificates correctly: chain of trust, SAN hostname checks, validity and clock skew, CRL and OCSP stapling, private CAs, pinning risk, and a production checklist.

JMBy JsonMind EngineeringLast reviewed: Nov 17, 2026Reviewed against primary specifications and linked sources.
Quick answer

TLS certificate verification proves that the leaf certificate chains to a trust anchor you chose, matches the requested hostname through its SAN, is valid now, permits server authentication, and is not known revoked under your policy. Check the chain, name, validity, key usage, and revocation; keep verification enabled in every client, and pin only with backup pins and a rotation plan.

Key takeaways
  • Verification is a chain-and-policy decision, not a decryption step; disabling it leaves encryption intact but removes protection against an active man-in-the-middle.
  • SAN is authoritative for hostname matching, CN is legacy, and wildcards match exactly one leftmost label.
  • Validity windows, key usage, extended key usage, and revocation are part of the certificate's meaning, not optional metadata.
  • Self-signed certificates and private CAs are legitimate when the trust anchor is distributed and managed explicitly, never when it arrives with a request.
  • Pinning narrows trust but creates an outage risk; ship backup pins, a rotation process, and a remote way to recover.

TLS certificate verification answers a narrow question: is this public key authorized to speak for this hostname, now, under the policy my client chose? Encryption is separate. A server can complete a key exchange with a self-signed certificate and produce a session no passive observer can read; without verification, an active attacker can terminate TLS and re-originate it. Verification turns confidentiality into authentication.

What certificate verification must establish

Verification combines path validation from RFC 5280 with name matching and local policy. The client builds a chain from the leaf certificate the server presents, through intermediates, to a root in its trust store. It checks signatures, names, dates, permitted uses, revocation, and any pinning rule the application defines. A failure at any layer invalidates the connection; silently disabling one check collapses every guarantee that depends on it.

LayerEvidenceTypical failure
Trust pathSignatures from leaf to trusted anchorUnknown or self-signed issuer; incomplete chain
IdentitySAN matches the requested hostCN-only certificate; wrong wildcard scope
TimenotBefore and notAfter around nowExpired leaf; clock far out of sync
UsagebasicConstraints, keyUsage, extendedKeyUsageCertificate issued for another purpose
RevocationCRL, OCSP response, or stapled responseRevoked key still accepted under soft-fail
PinSPKI digest in the application allowlistUnrotated pin after a key change

The common shortcut is turning verification off: curl -k, InsecureSkipVerify, verify=False, or a trust-all TrustManager. Each removes the entire table at once. A test environment needing a private certificate should add its CA to a scoped trust store, not disable the check.

Building and validating the chain of trust

A root CA is self-signed and distributed through an operating system, browser, or runtime trust store. An intermediate is signed by a root and carries basicConstraints: CA:TRUE; the leaf is signed by an intermediate and describes the server. Servers should send the leaf plus the intermediates that connect it to a trusted root, not the root itself: the client must already have it, and sending it only wastes bytes.

Path validation is stricter than "the signature verifies." The validator checks every signature, the CA basic constraint and keyCertSign usage, path length limits, name constraints, validity at each step, and required certificate policies. Path building may try alternate intermediates and cross-signed roots, and some stacks fetch missing issuers through the Authority Information Access extension. That fallback is convenience, not a guarantee: a server that omits its intermediate often works in a browser with a cached copy and fails in curl or a Java client with a cold trust store.

The certificate parser shows the subject, issuer, SANs, validity dates, key usage, and fingerprints of a captured certificate, usually faster than decoding base64 by hand. The same facts from the command line:

# Inspect the chain, names, dates, and usages the server presents
openssl s_client -connect api.example.com:443 -servername api.example.com -showcerts </dev/null 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates -text \
  | grep -A2 -E 'Subject Alternative Name|Extended Key Usage'

# Validate a leaf against an explicit trust store and intermediate
openssl verify -CAfile /etc/ssl/certs/ca-certificates.crt -untrusted intermediate.pem leaf.pem

SAN, CN, and hostname verification

The subjectAltName extension is authoritative for identity. A server certificate carries one or more dNSName entries, and IP addresses belong in iPAddress, not in a DNS name. The common name is legacy: browsers ignore it when SAN is present, Go has required SAN since 1.15, and CA/Browser Forum rules require the hostname in SAN. A client matching only CN rejects modern certificates and can accept names a correct client rejects.

Wildcard rules are narrower than assumed. *.example.com matches api.example.com but not example.com or api.eu.example.com; the wildcard must be the entire leftmost label. Internationalized names are compared as ASCII A-labels, and a trailing dot should be normalized away. Case does not matter.

Hostname verification is separate from SNI. The client sends the intended name in SNI so the server can choose a certificate, but must still verify that the returned certificate covers the name it intended to reach. Connecting to an IP and sending a Host header does not help: the certificate must contain that IP in SAN. When a proxy or load balancer fronts the origin, reproduce the request with the HTTP request workbench and compare the certificate the client receives with the one the origin serves.

Validity windows, clock skew, and time discipline

Every certificate carries notBefore and notAfter. Browsers hard-fail an expired leaf, but API clients, embedded devices, and hand-rolled socket code sometimes ignore dates. A not-yet-valid certificate is equally suspect: the client clock is wrong, it was deployed early, or a CA backdated it.

Clock skew is operational. Servers, containers, and devices without a real-time clock drift; a machine that boots with a 1970 timestamp rejects every valid certificate. Keep hosts on NTP, alert on drift, and allow a grace window of minutes, not days. Certificate times are UTC, so time zones are irrelevant, but a parser that mishandles UTCTime can still reject a valid certificate.

Expiry is predictable and should never start an incident. Automate renewal, monitor remaining lifetime, and alert at thresholds that reflect deployment speed. Short-lived certificates reduce the value of revocation but raise the value of automation: an expired certificate is an outage even when the key is fine.

Key usage, extended key usage, and constraints

A certificate states what it may be used for. basicConstraints distinguishes a CA from an end entity and can cap chain depth with pathLenConstraint. keyUsage lists permitted operations: digitalSignature is required for TLS 1.3 and ECDHE in TLS 1.2, keyEncipherment covers only TLS 1.2 RSA key transport, and keyCertSign belongs on CAs. A leaf with only keyEncipherment cannot sign the TLS 1.3 CertificateVerify message.

extendedKeyUsage narrows the purpose. A TLS server needs serverAuth; a mutual-TLS client certificate needs clientAuth. Code-signing and email-protection certificates may chain correctly and still be wrong for TLS. Validators differ on propagating EKU constraints down the chain, so a private CA should issue purpose-specific intermediates rather than rely on every client enforcing the same rule.

Name constraints extend this to namespaces: a private CA can be limited to example.internal so a compromised intermediate cannot issue for other domains. Not every client enforces every constraint, so scope a private CA narrowly and audit it rather than trusting it broadly.

Revocation: CRL, OCSP, and stapling

A certificate can be revoked before it expires. Certificate revocation lists are signed files published by the CA; the Online Certificate Status Protocol answers a status query for one certificate. CRLs are simple but grow large and stale; delta and partitioned CRLs help, and distribution points must be reachable. OCSP is fresher and smaller, but costs a round trip, leaks the checked certificate to the CA, and adds an availability dependency.

OCSP stapling moves the response into the handshake: the server fetches a signed OCSP response and presents it with its certificate, so the client does not contact the CA. The status_request extension carries the request; must-staple tells clients to reject a server that fails to staple. Stapling improves privacy and latency but does not make revocation universal. Many browsers soft-fail when a responder is unreachable, Chrome relies on its own CRLSets, and Apple has its own checking path.

The conclusion is uncomfortable but correct: revocation is best-effort. Keep lifetimes short, staple where supported, monitor your own certificates, and do not treat an unreachable responder as proof of validity. If a key is compromised, revocation helps only the clients that actually check.

Self-signed certificates and private CAs

A self-signed certificate is signed by its own key and has no external trust. That is fine for local development, test fixtures, and a service whose clients explicitly trust it. It is not a safe production default: no public trust store contains it, and every client that accepts it has been taught to accept an unverified identity.

A private CA is the managed version. Create a root, protect its key offline, issue short-lived leaves from an intermediate, and distribute the root through device management or an application trust store that ships with the product. Name constraints and purpose-specific intermediates limit the blast radius. Mutual TLS fits here: the server validates client certificates against a CA it chose, with clientAuth EKU and its own revocation policy.

The dangerous pattern is trusting a CA bundle supplied at runtime by a user, tenant, or HTTP response. That makes the attacker's CA a trust anchor. If a product must support customer-provided CAs, isolate each tenant's trust store, verify the bundle's provenance and checksum, and never let one tenant's bundle affect another's connections. SSL_CERT_FILE and curl --cacert are debugging aids, not production bypasses.

Pinning, fingerprints, and rotation

Pinning narrows trust from "any public CA" to "this key or set of keys." Pin the Subject Public Key Info digest, normally SHA-256, not the leaf certificate: the SPKI survives renewal when the key is reused and avoids coupling clients to serial numbers and dates. A leaf pin breaks on every renewal even when the key is unchanged.

The operational risk is severe. A pin deployed without a backup becomes an outage when the key rotates, the CA changes, or a CDN replaces a managed certificate. Ship at least two pins, for the current key and the next, stage the change with an overlap window, and keep a signed remote configuration or release path that can remove a bad pin. In mobile apps a pinning bug can brick every installed client, and an app-store release is not an instant rollback.

Fingerprints are useful without pinning. A SHA-256 fingerprint of the DER certificate identifies it unambiguously; SHA-1 is deprecated for security decisions. Before importing a downloaded CA bundle, verify its published checksum with the SHA hash generator. Pinning does not replace chain validation: verify the chain, then enforce the pin, or a mis-issued certificate from the pinned CA passes.

TLS 1.2 versus TLS 1.3 handshake differences

Verification rules are identical across versions, but where the certificate appears and how key possession is proved differ. In a full TLS 1.2 handshake the server sends ServerHello, its Certificate in plaintext, then ServerKeyExchange with ephemeral key parameters and a signature over the transcript. The client finishes the key exchange, sends ChangeCipherSpec, and both sides exchange Finished. With ECDHE the ServerKeyExchange signature proves the leaf key; with static RSA key transport there is no such signature, which is why TLS 1.3 removed it.

TLS 1.3 completes a one-round-trip handshake. After ClientHello and ServerHello, the rest is encrypted: EncryptedExtensions, the server Certificate, CertificateVerify, and Finished. CertificateVerify signs the transcript with the leaf private key, so the client still gets proof of possession, but a middlebox cannot read the certificate without keys. Renegotiation, compression, and static RSA are gone; resumption uses a pre-shared key in a ticket.

Resumption surprises people. A resumed TLS 1.3 session exchanges no certificates; authentication comes from the earlier ticket. That is normally desirable, but a client requiring a fresh certificate check on every connection must disable resumption or bind its policy to the session. Protocol version is not a substitute for verification: TLS 1.3 with verification disabled is as vulnerable to a man-in-the-middle as TLS 1.2.

Verification checklist and common failure modes

Verify from the outside, then from the client that matters. A browser tab is not enough when production uses Go, Java, Python, or a mobile SDK with its own store.

CheckHow to testPass criteria
Trust pathopenssl verify against the client trust storeChain ends at a trusted root; every signature validates
HostnameCompare the requested name with SAN entriesExact dNSName or valid one-label wildcard match
ValidityInspect dates against UTC nowNow inside the window on every relevant chain element
UsageRead keyUsage, extendedKeyUsage, basicConstraintsdigitalSignature and serverAuth present on the leaf
RevocationCheck stapled OCSP or the CA CRL/OCSP endpointStatus good, or an explicit documented soft-fail policy
ProtocolRecord the negotiated version and cipherTLS 1.2 or 1.3 with a forward-secret suite
PinCompare the SPKI digest with the allowlistCurrent or backup pin matches; rotation documented

A correct client configuration makes verification the default and never sources a trust anchor from request data:

import tls from "node:tls";

const socket = tls.connect({
  host: "api.example.com",
  servername: "api.example.com",               // SNI name and the name being verified
  rejectUnauthorized: true,                    // keep verification on in production
  minVersion: "TLSv1.2",
  checkServerIdentity: tls.checkServerIdentity // SAN-aware default check
});

socket.on("secureConnect", () => {
  console.log(socket.getProtocol(), socket.getPeerCertificate().subjectaltname);
});

Incidents follow a short list. Disabling verification (-k, InsecureSkipVerify, verify=False, trust-all managers) turns TLS into an encrypted channel to an unknown party. Matching only CN rejects modern certificates. Ignoring expiry leaves an outage waiting for a deploy. Trusting a user-supplied CA bundle hands the attacker the trust anchor. Pinning without a rotation plan turns a routine certificate change into a client-side outage.

Treat verification as fail-closed policy. Log why a chain was rejected, never downgrade silently, and test with the production trust store. A certificate that verifies in Chrome but not in your service is a policy difference that will surface eventually.

Frequently asked questions

Does TLS still encrypt traffic if certificate verification is disabled?

Yes, the session can still be encrypted, but you no longer know who holds the other end. An active attacker can terminate TLS with a certificate you did not verify and open a second connection to the real server, reading and modifying everything in between.

Why does a browser accept a certificate that curl or a Java client rejects?

The clients use different trust stores, chain-building rules, and revocation policies. A browser may have cached an intermediate or fetched it through the certificate's AIA extension, while curl trusts only the local CA bundle. Java often needs the full intermediate chain in the server handshake.

Is the CN field still used for hostname matching?

Practically no. Modern browsers, Go, and current RFC guidance treat subjectAltName as authoritative and ignore CN when SAN is present. Certificates issued for public TLS must carry the hostname in SAN, so matching CN alone rejects valid certificates and can accept ambiguous ones.

Do short-lived certificates make OCSP and CRLs unnecessary?

They reduce the exposure window but do not eliminate revocation. Short lifetimes depend on reliable automation, and a stolen key can still be used until the certificate expires. Treat revocation as best-effort defense in depth, staple OCSP responses, and never make availability depend on a responder that may be down.

When should I pin a certificate, and how do I rotate pins safely?

Pin when you control both ends and the threat of a mis-issued certificate outweighs the operational cost, such as a mobile app calling your own API. Pin the SPKI hash, ship at least one backup pin for the next key, define an overlap window, and keep a signed remote configuration or release path that can remove a bad pin.

Reviewed against primary specifications and linked sources.

JsonMind guides are written and reviewed by the engineering team. We check each guide against the relevant RFC or vendor documentation, link the primary sources, and update the guide when behavior changes.

Primary sources are linked at the end of each guide.

References

Put this guide into practice

Browse all tools

Open the browser tool. Inputs stay in your browser and are not uploaded to the business server.

Related guides

All guides