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.
Two TLS connections, two verdicts
Cloudflare terminates TLS at the edge, then opens a second TLS connection to your origin. The browser validates the first; the zone's encryption mode governs the second.
- 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.
%%{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.
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.
| Mode | Visitor to edge | Edge to origin | Certificate validated? | Typical symptom | Availability |
|---|---|---|---|---|---|
| Off | HTTP only | HTTP | No | No HTTPS anywhere | All plans |
| Flexible | HTTPS when used | HTTP | No | Loop with an origin HTTPS redirect | All plans |
| Full | HTTPS when used | Visitor's scheme | No | Works with expired or self-signed certificates | All plans |
| Full (strict) | HTTPS when used | HTTPS with validation | Yes | 526 on bad or incomplete chains | All plans |
| Strict (SSL-Only Origin Pull) | HTTPS | Always HTTPS | Yes | 526 for the same reasons | Enterprise 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 certificate | Full | Full (strict) |
|---|---|---|
| Valid, matching, complete chain | Serves | Serves |
| Self-signed or expired | Serves | 526, validation fails |
Valid but issued for www.example.com, requested as shop.example.com | Serves | 526, name mismatch |
| No TLS listener on port 443 | 525 | 525 |
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.
%%{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.
| Symptom | What failed | First check |
|---|---|---|
526 | The edge reached the origin and rejected its certificate | Expiry, CN/SAN, issuer trust, missing intermediate |
525 | The handshake never completed | Port 443 open, a certificate served, SNI and cipher support |
520, 521, 522, 524 | Connection or timing failure | Origin health and network path, not the TLS mode |
ERR_TOO_MANY_REDIRECTS | A scheme disagreement | Flexible plus an origin redirect |
NET::ERR_CERT_AUTHORITY_INVALID | An Origin CA certificate served directly | Paused zone or grey-clouded record |
| HSTS hard failure | A stored policy plus an invalid certificate | Renew the certificate; there is no bypass until expiry |
Figure 4 contrasts the loop, the validated path, and the 526 path.
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.
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.
| Step | Action | Expected |
|---|---|---|
| 1 | Generate the CA, leaf, and extension file, then start the server | openssl verify prints leaf.crt: OK |
| 2 | Request the matching name with --cacert | HTTP 200, and s_client reports Verify return code: 0 (ok) |
| 3 | Request as wrong.example.com, then without the CA | A name-mismatch error, then an untrusted-issuer error |
| 4 | Hosted half: install an Origin CA or public certificate, proxy the record, set Full (strict) | curl -sSI shows server: cloudflare and a cf-ray |
| 5 | Break it with a certificate whose SAN misses the hostname | 526 per documented behaviour, while the origin still answers locally. Switch to Full: the page loads again, proving Full encrypts without authenticating |
| 6 | Test the loop on a disposable hostname: Flexible plus an origin HTTP-to-HTTPS redirect | ERR_TOO_MANY_REDIRECTS; Full (strict) stops it |
| 7 | Enable HSTS with a 1-month max-age and includeSubDomains off | Header 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.
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.
A matching certificate is not a working site. The wildcard covered the name; the application behind it did not exist.
Self-check.
- 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.
- 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.
- 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.
- 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.