Back to Cloudflare

Two TLS Connections: Secure the Browser and the Origin

November 4, 2026 Updated November 5, 2026 Wasil Zafar 18 min read

Explain certificates, trust, and Full (strict) operation

Table of Contents

  1. The Browser Trusts the Edge Certificate
  2. The Edge Must Also Trust the Origin
  3. Universal SSL, Origin CA, and Certificate Lifecycle
  4. Redirects, HSTS, SNI, and Failure Modes
  5. Secure a Controlled Origin With Full Strict Validation
  6. Test Both TLS Legs and Detect an Invalid Origin Certificate

The Browser Trusts the Edge Certificate

A padlock describes one connection, not the whole path. You open https://shop.example.com on venue Wi-Fi. The browser completed a TLS handshake with a server whose certificate names shop.example.com and chains to a trusted root. That says nothing about whether the shop is honest.

Think of a parcel relay: you check the first courier's badge, then the depot re-packs the box and checks the second driver's badge. Two handoffs, two decisions; your padlock covers the first.

  • TLS encrypts and authenticates a connection before HTTP is sent.
  • A certificate binds a public key to names, with validity dates and Subject Alternative Names (SANs).
  • A certificate authority (CA) issues certificates; its root is installed in browsers. A trust chain runs from leaf through intermediates to that root.
  • SNI is the hostname sent at the start of the handshake so a shared address can choose a certificate. Cloudflare uses it for all Universal SSL certificates.
  • HSTS tells a browser to refuse plain HTTP and certificate bypass for a set period.

The edge chooses by SNI. The browser checks the name, dates, and chain; if all pass, HTTP is sent. The edge then selects the certificate by SNI from the zones sharing an anycast address (Figure 1), and the origin plays no part in that decision.

The Browser Trusts the Edge Certificate
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    subgraph CLIENT["Browser boundary"]
        B["Browser opens https://shop.example.com"]
        T["OS and browser trust store"]
        V{"Name matches, in date, chain trusted?"}
        W["Warning page: HTTP never sent"]
    end
    subgraph EDGE["Cloudflare edge boundary"]
        S["SNI router reads shop.example.com"]
        C["Selects edge certificate and key"]
        K["TLS keys established, HTTP decrypted"]
    end
    subgraph ORIGIN["Origin boundary"]
        O["Origin, reached on a second connection"]
    end
    B -->|"1 ClientHello with SNI"| S
    S -->|"2 choose certificate"| C
    C -->|"3 leaf plus intermediates"| V
    T -->|"4 trusted roots"| V
    V -->|"no"| W
    V -->|"yes"| K
    K -->|"5 HTTP request"| O
    classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
    classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
    classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
    classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
    classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
    class C,O primary;
    class B,T,S,K secondary;
    class V ok;
    class W warn;

SNI is sent before encryption, which is why the edge can choose a certificate. The origin arrow is a separate connection. Figure 2 draws the legs as distinct trust zones.

Two TLS legs, browser to edge and edge to origin The browser verifies the edge certificate. The edge verifies the origin only in Full (strict). The padlock covers leg one. Leg 1: browser verifies the edge Leg 2: edge verifies the origin Browser trust store of roots checks name and dates checks chain Cloudflare edge edge cert and key chosen by SNI TLS terminates HTTP is visible Origin origin certificate leaf plus chain checked if Full (strict) TLS + SNI cert chain TLS Padlock covers leg 1 only. In Flexible, leg 2 is plain HTTP.

The padlock proves only the first leg

It shows that the visitor reached a Cloudflare edge. It does not show that the edge reached your origin over TLS, or that the origin's certificate was checked.

The Edge Must Also Trust the Origin

The edge is a TLS client too. It connects to the origin, sends SNI, receives a chain, and validates it according to the mode. "Encrypted" and "verified" are not synonyms, and that gap is where most TLS incidents live.

ModeVisitor to edgeEdge to originCertificate validated?Typical symptomAvailability
OffHTTP onlyHTTPNoNo HTTPS anywhereAll plans
FlexibleHTTPS when usedHTTPNoLoop with an origin HTTPS redirectAll plans
FullHTTPS when usedVisitor's schemeNoWorks with expired or self-signed certificatesAll plans
Full (strict)HTTPS when usedHTTPS with validationYes526 on bad or incomplete chainsAll plans
Strict (SSL-Only Origin Pull)HTTPSAlways HTTPSYes526 for the same reasonsEnterprise zones

One origin, four outcomes. The same address at 203.0.113.10 behaves differently depending on what the origin serves and which mode the zone uses.

Origin certificateFullFull (strict)
Valid, matching, complete chainServesServes
Self-signed or expiredServes526, validation fails
Valid but issued for www.example.com, requested as shop.example.comServes526, name mismatch
No TLS listener on port 443525525

Flexible plus an origin HTTP-to-HTTPS redirect loops; Full breaks it, because the edge stops sending plain HTTP.

Full (strict) has four requirements. An unexpired certificate, issued by a publicly trusted CA or Cloudflare Origin CA, naming the hostname, and served with a complete chain on port 443. A missing intermediate explains many 526s that look fine in a browser. Both Full modes match the visitor's scheme, so with Always Use HTTPS off, Cloudflare may connect over HTTP even in Full (strict).

The mode is a zone setting on every plan, overridable per hostname with a configuration rule. Origin CA is free but trusted only by Cloudflare. Advanced Certificate Manager is a paid add-on required for Custom Origin Trust Store. Total TLS requires it plus a full DNS setup. Workers subrequests outside your zone always use Full (strict).

Figure 3 follows the second handshake and its failure branches.

The Edge Must Also Trust the Origin
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
sequenceDiagram
    autonumber
    participant B as Browser
    participant E as Cloudflare edge
    participant O as Origin
    B->>E: ClientHello with SNI shop.example.com
    E-->>B: Edge certificate and chain
    Note over B: Padlock decided here, leg 1
    B->>E: Encrypted HTTP request
    E->>O: New handshake, SNI shop.example.com
    alt Valid, matching, unexpired chain
        O-->>E: Leaf plus intermediates
        E->>O: Request over TLS
        O-->>E: Response
        E-->>B: Response
    else Self-signed, expired, wrong name, or incomplete chain
        O-->>E: Untrusted certificate
        E-->>B: 526 invalid SSL certificate
    else No TLS listener or cipher mismatch
        O--xE: Handshake fails
        E-->>B: 525 SSL handshake failed
    end

Default to Full (strict)

Choose it when the origin can present a verifiable certificate. Treat Full as a temporary mode with a named owner and an expiry date, not as a resting state.

Universal SSL, Origin CA, and Certificate Lifecycle

Two lifecycles run in parallel; one is automatic. Universal SSL renews itself at the edge, while the origin certificate is yours to inventory, monitor, and replace.

Universal SSL covers the edge. Cloudflare issues free public certificates to every activated domain and renews them. On a full setup, coverage is the apex and first-level subdomains; dev.www.example.com is not covered. Certificates last 90 days, with renewal starting 30 days before expiry. Universal SSL is served only for proxied records. Free zones receive ECDSA only; paid zones receive RSA and ECDSA.

Origin CA covers the second leg. It is free on all plans, valid for up to 15 years, supports 200 SANs, and allows wildcards covering one level. It cannot include IP addresses. Its defining property is also its trap: Cloudflare trusts it, and nothing else does.

The trap has a predictable failure. In one documented scenario, a team installs a 15-year Origin CA certificate and sets Full (strict). Months later they add a status page on a vendor host and grey-cloud the record. Visitors get NET::ERR_CERT_AUTHORITY_INVALID, because the browser now talks directly to a certificate no public trust store knows.

Lifecycle discipline follows. Inventory origin certificates with hostnames and expiry dates, because Cloudflare sends no expiration notices for Origin CA. Monitor with validation on; curl -k reports success while visitors see 526. Keep the chain complete. Prefer automation over very long-lived certificates, which hide expiry and key rotation. Plan Total TLS before adding deep subdomains.

Origin CA is not a public certificate

A Cloudflare Origin CA certificate is not a general-purpose certificate. It protects only the Cloudflare-to-origin leg, so pausing Cloudflare or grey-clouding the record exposes visitors to an untrusted-certificate error.

Automatic SSL/TLS will not undo a bad expiry

Automatic SSL/TLS can raise a zone's mode but will not lower it when an origin certificate expires. Expiry therefore becomes a 526, not a silent fallback to Full.

Redirects, HSTS, SNI, and Failure Modes

Redirects and HSTS can turn a working setup into an outage. One is a routing decision that is easy to undo; the other is a browser policy that is not.

Redirects belong at the edge, not at both ends. The classic loop is Flexible plus an origin redirect: the edge sends HTTP, the origin answers 301 https://..., and the edge sends HTTP again. Fix it with Full or Full (strict), or remove the origin redirect. Always Use HTTPS does not fix mixed content.

HSTS is a one-way door

HSTS is a browser policy, not a redirect. Once a browser stores the header, it rewrites HTTP to HTTPS and refuses certificate bypass for that lifetime. The dashboard offers 1 to 12 months, plus includeSubDomains and preload.

includeSubDomains applies the policy to subdomains that may lack HTTPS, making them unreachable. Preload needs a 12-month max-age and list submission, and removal takes months.

Setting max-age=0 stops new headers, but stored policies persist until expiry. During that window a certificate error is a hard failure with no "proceed" link.

SNI picks the certificate, not the site. SNI selects the certificate on a shared edge address. If DNS points a name at an edge with no certificate for it, the server may present a default certificate: the handshake succeeds, but the browser's name check fails.

Read the error before changing the mode. Each symptom points at a different layer.

SymptomWhat failedFirst check
526The edge reached the origin and rejected its certificateExpiry, CN/SAN, issuer trust, missing intermediate
525The handshake never completedPort 443 open, a certificate served, SNI and cipher support
520, 521, 522, 524Connection or timing failureOrigin health and network path, not the TLS mode
ERR_TOO_MANY_REDIRECTSA scheme disagreementFlexible plus an origin redirect
NET::ERR_CERT_AUTHORITY_INVALIDAn Origin CA certificate served directlyPaused zone or grey-clouded record
HSTS hard failureA stored policy plus an invalid certificateRenew the certificate; there is no bypass until expiry

Figure 4 contrasts the loop, the validated path, and the 526 path.

Three edge-to-origin outcomes: loop, success, and 526 Flexible with an origin HTTPS redirect loops. Full (strict) with a valid chain returns 200. Full (strict) with an invalid certificate returns 526. Browser Edge Origin Flexible + origin redirect Full (strict), valid chain Full (strict), invalid cert HTTPS HTTP 301 Retries over HTTP forever ERR_TOO_MANY_REDIRECTS HTTPS verify Name, dates, chain pass 200 from origin HTTPS fails Expired, self-signed, wrong name, or bad chain 526 invalid certificate Same visitor URL. Only the edge-to-origin leg and its validation differ.

Every mode trades one cost for another. Full (strict) costs automation but verifies the leg you cannot see; Flexible removes encryption while leaving the padlock. HSTS costs recoverability; SNI costs compatibility with very old clients.

Secure a Controlled Origin With Full Strict Validation

The exercise has two halves: a local fixture and an optional hosted check. The fixture runs entirely on your machine; the hosted half needs a zone.

Build the fixture once. The extension file supplies the SAN that the leaf subject does not.

subjectAltName=DNS:origin.example.com
# 1. Lab root CA
openssl req -x509 -newkey rsa:2048 -nodes -keyout ca.key -out ca.crt \
  -days 2 -subj "/CN=Lab Origin CA"

# 2. Leaf key, CSR and signature for the origin name
openssl req -newkey rsa:2048 -nodes -keyout leaf.key -out leaf.csr \
  -subj "/CN=origin.example.com"
openssl x509 -req -in leaf.csr -CA ca.crt -CAkey ca.key \
  -CAcreateserial -out leaf.crt -days 2 -extfile ext.cnf

# 3. Verify the leaf against the lab root
openssl verify -CAfile ca.crt leaf.crt

# 4. Serve on 8444 in one shell, then request the name from another
openssl s_server -accept 8444 -cert leaf.crt -key leaf.key -www
curl --cacert ca.crt --resolve origin.example.com:8444:127.0.0.1 \
  https://origin.example.com:8444/
Guided exercise

Secure a Controlled Origin With Full Strict Validation

Execution status: fixture executed 2026-11-04 (macOS, OpenSSL 3.2.0, curl 8.5.0). The Cloudflare-hosted half is design-only and was not run; no zone or origin was provisioned.

Prerequisites. A domain on Cloudflare Free, one proxied record, a host you control, and local openssl plus curl.

StepActionExpected
1Generate the CA, leaf, and extension file, then start the serveropenssl verify prints leaf.crt: OK
2Request the matching name with --cacertHTTP 200, and s_client reports Verify return code: 0 (ok)
3Request as wrong.example.com, then without the CAA name-mismatch error, then an untrusted-issuer error
4Hosted half: install an Origin CA or public certificate, proxy the record, set Full (strict)curl -sSI shows server: cloudflare and a cf-ray
5Break it with a certificate whose SAN misses the hostname526 per documented behaviour, while the origin still answers locally. Switch to Full: the page loads again, proving Full encrypts without authenticating
6Test the loop on a disposable hostname: Flexible plus an origin HTTP-to-HTTPS redirectERR_TOO_MANY_REDIRECTS; Full (strict) stops it
7Enable HSTS with a 1-month max-age and includeSubDomains offHeader max-age=2592000. Set max-age to 0 and browsers keep the old policy until expiry

Failure checks. 526 means validation failed; 525 means the handshake failed; a browser-only warning usually means an Origin CA certificate is served directly; a loop means the scheme decision is split.

Cost. Domain registration is typically USD 10–15 per year. Free plan, Universal SSL, Origin CA, and this exercise are USD 0. Advanced Certificate Manager is a paid add-on, needed only for deep subdomains or a custom trust store.

Cleanup. Stop s_server, delete the lab keys and certificates, remove the DNS record, set HSTS max-age to 0, and restore the previous mode.

The exercise separates three questions: did the handshake complete, did the certificate validate, and did the application answer? A 526 fails the second check; a 525 fails the first.

Test Both TLS Legs and Detect an Invalid Origin Certificate

Two artifacts prove the legs: the edge certificate and an origin test.

Leg 1 is observable from anywhere. Run the two commands below and compare the fields, not just the padlock.

# Read the edge certificate
openssl s_client -connect developers.cloudflare.com:443 \
  -servername developers.cloudflare.com

# Read what the edge returns
curl -sSI https://developers.cloudflare.com/
# Fields returned (summarised), 2026-11-04
subject=CN=developers.cloudflare.com
issuer=C=US, O=Google Trust Services, CN=WE1
validity=2026-10-30 to 2027-01-28
Verify return code: 0 (ok)

# Response headers, same date
server: cloudflare
cf-ray: a5570e9caed0f3ce-DUB
strict-transport-security: max-age=15552000; preload

These are pass evidence, not a recommendation for your zone. A different hostname, plan, or certificate authority will show different values on the same fields.

Pass evidence, leg 2 (fixture). With the lab CA and a matching name, the request returned 200 and the verification code was 0 (ok).

Failures are just as legible. Three commands separate a trust failure, a name failure, and an edge that serves a default certificate.

# Trust failure: a self-signed leaf answers on the origin
curl --resolve origin.example.com:8444:127.0.0.1 \
  https://origin.example.com:8444/

# Name failure: the CA is trusted, the requested name is not in the SAN
curl --cacert ca.crt --resolve wrong.example.com:8444:127.0.0.1 \
  https://wrong.example.com:8444/

# Edge SNI for a name the zone does not own
openssl s_client -connect example.com:443 -servername no-such-name.example.com
curl -sSI https://no-such-name.example.com/
# Errors returned (summarised), 2026-11-04
SSL certificate problem: self-signed certificate
SSL: no alternative certificate subject name matches target host name

# The edge answered with a default certificate, then the request failed
certificate: CN=example.com
SANs: example.com, *.example.com
HTTP/530

A matching certificate is not a working site. The wildcard covered the name; the application behind it did not exist.

Self-check.

  1. A site shows a padlock while the origin certificate is expired. Which mode allows that? Full or Flexible; neither validates the origin. Only Full (strict) and Strict (SSL-Only Origin Pull) check it.
  2. A 526 appears after renewal. What comes first? Check that the new SANs cover the hostname and that the chain includes intermediates, then expiry and trust. A 526 means the handshake succeeded, so a closed port is the wrong hypothesis; that is 525.
  3. Why does Flexible loop with an origin HTTPS redirect? The edge always contacts the origin over HTTP, so each redirect returns the browser to a request the edge repeats over HTTP.
  4. You enable HSTS for 12 months with includeSubDomains, then move a subdomain to a host without TLS. What happens? That subdomain is unreachable for the remaining lifetime; max-age 0 stops new headers, but stored policies persist until expiry.

Unresolved limitations. No Cloudflare-hosted origin was provisioned, so the 526 and 525 branches are documented behaviour plus local analogues, not hosted measurements. The fixture used a private CA, not Origin CA. HSTS preload removal, configuration rules, Custom Origin Trust Store, Total TLS, and Strict (SSL-Only Origin Pull) were not exercised. Re-check limits, entitlements, and prices before building.

References (verified 2026-11-04):

  • SSL/TLS overview: https://developers.cloudflare.com/ssl/
  • Encryption modes: https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/
  • Full (strict): https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/full-strict/
  • Flexible: https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/flexible/
  • Strict (SSL-Only Origin Pull): https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/ssl-only-origin-pull/
  • Universal SSL: https://developers.cloudflare.com/ssl/edge-certificates/universal-ssl/
  • Universal SSL limitations: https://developers.cloudflare.com/ssl/edge-certificates/universal-ssl/limitations/
  • Certificate validity periods: https://developers.cloudflare.com/ssl/reference/certificate-validity-periods/
  • Origin CA: https://developers.cloudflare.com/ssl/origin-configuration/origin-ca/
  • Advanced Certificate Manager: https://developers.cloudflare.com/ssl/edge-certificates/advanced-certificate-manager/
  • Total TLS: https://developers.cloudflare.com/ssl/edge-certificates/additional-options/total-tls/
  • HSTS: https://developers.cloudflare.com/ssl/edge-certificates/additional-options/http-strict-transport-security/
  • Redirect loops: https://developers.cloudflare.com/ssl/troubleshooting/too-many-redirects/
  • Error 525: https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-525/
  • Error 526: https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-526/

Next in the Series

In Protect the Origin Behind the Proxy, we'll explore Close bypass paths and preserve a trustworthy client identity.