Dev.to Security πŸ” Cybersecurity πŸ‘ 2 πŸ“– 18 min read

Why Zscaler broke kubectl: TLS and mTLS explained the easy way

Here's a story that plays out in a lot of engineering teams. The company rolls out Zscaler, or any proxy that inspects HTTPS traffic. Browsers keep working. Then kubectl against the EKS cluster stops working, with one o

Here's a story that plays out in a lot of engineering teams.

The company rolls out Zscaler, or any proxy that inspects HTTPS traffic. Browsers keep working. Then kubectl against the EKS cluster stops working, with one of these:

Unable to connect to the server: read tcp ...: read: connection reset by peer
Unable to connect to the server: tls: failed to verify certificate:
x509: certificate signed by unknown authority

The fix is usually one request to IT. Understanding why it breaks is the interesting part. It takes you through certificates, CAs, handshakes and what an inspecting proxy actually does to a connection. Most explanations skip the step where it all fits together, so this post doesn't. No cryptography math. Just who proves what to whom, in what order, using which file. By the end you should be able to look at any TLS error, in kubectl or in a browser, and say exactly which check failed and why.

1. Three files. That's all.

Everything in this post uses only three kinds of file.

File Think of it as Is it shared?
Certificate (apiserver.crt, me.crt) An ID card: a name plus a public key, signed by a CA Yes. It's public and gets sent to the other side.
Private key (apiserver.key, me.key) The thing that proves the ID card is yours Never. It doesn't leave its machine.
CA certificate (ca.crt) The reference stamp everyone checks against Yes, it's public. Its partner ca.key does the signing and stays locked away.

A CA (Certificate Authority) is just a key pair whose job is to sign other certificates. ca.key signs. ca.crt can only check.

Two terms you'll see everywhere:

  • TLS: only the server proves who it is. Every HTTPS website works like this.
  • mTLS (mutual TLS): the server proves who it is, then the client does too. Plain Kubernetes with client certificates works like this.

2. The two kinds of signing (the part that confused me most)

Here's where I got stuck. The CA already signed apiserver.crt. So what is this other signature the server makes with apiserver.key?

They are two different signatures, made by different keys, at different times, and checked with different things.

 SIGNATURE 1: THE STAMP              SIGNATURE 2: THE FRESH SIGNATURE
 made once, when the cert is made    made on every single connection

 ca.key --signs--> apiserver.crt     apiserver.key --signs--> this handshake
 ca.key --signs--> me.crt            me.key        --signs--> this handshake

 checked with: ca.crt                checked with: the public key
                                                   printed inside the cert

 proves: "this cert is genuine"      proves: "the sender owns this cert"

Why do we need both? Because certificates are public. Every client that connects to the API server receives a copy of apiserver.crt. If showing the certificate were enough, anyone could keep a copy and replay it. So the owner must also sign something new, unique to this connection, with the private key that only the owner has.

Think of a passport at a border. The government seal shows the passport is real: that's signature 1. Your face matching the photo shows it's yours: that's signature 2. A stolen passport has a genuine seal but fails the face check.

What exactly gets signed on each connection?

Not just one random number. It's a fingerprint (a hash) of all the handshake messages so far:

  • the client's hello, which carries a brand-new random number
  • the server's reply, with its own random number
  • the values both sides use to build the encryption key

Because the client's random number is new every time, a signature recorded yesterday is useless today. And because the key-building values are inside the signature, nobody in the middle can swap in their own.

Do these keys encrypt my data?

No. apiserver.key and me.key only prove identity. During the same handshake, both sides also build a fresh session key that is never sent over the wire. That session key encrypts your traffic, and it's thrown away when the connection ends.

The one rule

To prove who you are: show your certificate, and sign this connection's handshake with your private key.

To check someone: verify the stamp on their certificate with ca.crt, then verify their fresh signature with the public key inside their certificate.

3. The four checks

Whoever receives a certificate runs these four checks on it, automatically. You never do them by hand; your job is to give your tools the right files. They also map to the four TLS errors you'll actually debug.

Check Question Uses Error when it fails
Stamp Was this cert signed by a CA I trust? ca.crt (or the OS trust store) x509: certificate signed by unknown authority
Name Is this cert for the name I connected to? The address you used x509: certificate is valid for X, not Y
Date Is it valid today? The dates on the cert x509: certificate has expired or is not yet valid
Key Does the sender hold this cert's private key? The public key inside the cert The handshake fails

The name check in one minute

Every server certificate carries a list of names it's valid for, called the SAN (Subject Alternative Name). For an API server, that list might be:

kubernetes
kubernetes.default
10.96.0.1
ABC123.gr7.ap-south-1.eks.amazonaws.com

kubectl checks that the address in your kubeconfig is on that list.

Why it matters: one CA signs many certificates (the API server, etcd, every kubelet). All of them carry a genuine stamp. The name check makes sure a real certificate for some other machine can't stand in for the API server. Browsers rely on it too: a real google.com certificate must never be accepted for yourbank.com, even though a trusted CA signed it.

You'll hit this in real life when you connect by an IP or DNS name that wasn't on the list when the certificate was made.

(The API server skips the name check on your client certificate. Your name is what it reads afterwards, to decide your permissions.)

4. What can an impostor actually do?

The easiest way to see why you need both signatures is to try to cheat.

 The impostor has...                 Stamp  Name  Date  Key   Result
 ----------------------------------  -----  ----  ----  ----  ---------
 a copy of the real apiserver.crt    pass   pass  pass  FAIL  rejected
 its own cert for the same name      FAIL   pass  pass  pass  rejected
 the stolen ca.key                   pass   pass  pass  pass  ACCEPTED
  • A copied certificate. The stamp is real, but the impostor can't sign this connection's handshake without apiserver.key. Rejected by the key check.
  • Its own certificate. It holds the matching key, but it can't get ca.key to sign the certificate. Rejected by the stamp check. Remember this row. It's exactly what Zscaler does.
  • A stolen ca.key. Now it can mint a brand-new certificate for the API server's name, with its own key pair, stamped by the real CA. Every check passes. It could also mint a client certificate with O=system:masters, which means full cluster-admin.

Note that having ca.crt doesn't let anyone pose as the CA, because ca.crt can only check. Only ca.key can sign. That's why ca.key is the most sensitive file in a cluster. On kubeadm it lives only on the control plane, readable by root. On EKS, AWS holds it and you never see it.

5. Who holds which file in Kubernetes

Your laptop: ~/.kube/config

Field Is really Used for
server: https://... The address The name check
certificate-authority-data ca.crt (base64) Checking the server
client-certificate-data me.crt Your ID: CN=satyaki is your user, O=devops your group
client-key-data me.key Proving the cert is yours

Control plane: /etc/kubernetes/pki (kubeadm)

File Used for
apiserver.crt + apiserver.key The server's ID and its proof
ca.crt Checking client certs (--client-ca-file)
ca.key Signing new certs only. Never used when you log in.

How the certificates got made, once, long before any login:

  1. kubeadm init creates the CA: ca.key + ca.crt.
  2. ca.key signs apiserver.crt, which lists every name the server answers to.
  3. You make me.key and a request (CSR) on your laptop. A CertificateSigningRequest object carries it to the cluster, an admin runs kubectl certificate approve, the cluster signs it with ca.key, and you download me.crt.

Private keys never travel. Only requests and signed certificates do.

6. Every kubectl call, step by step (mTLS)

This runs on every single kubectl command, in this order. ca.key isn't involved at all.

 kubectl (your laptop)                    API server (control plane)
 has: ca.crt, me.crt, me.key              has: ca.crt, apiserver.crt,
                                               apiserver.key
    |                                                |
    |-- 1. hello + a new random number ------------->|
    |                                                |
    |<-- 2. apiserver.crt ---------------------------|  SERVER
    |<--    signature made with apiserver.key -------|  PROVES
    |<--    "now show me yours" ---------------------|
    |                                                |
 3. kubectl checks the server:                       |
    stamp (ca.crt), name, date, signature            |
    |                                                |
    |-- 4. me.crt ---------------------------------->|  YOU
    |--    signature made with me.key -------------->|  PROVE
    |                                                |
    |                                                |  5. API server
    |                                                |     checks you:
    |                                                |     stamp (ca.crt),
    |                                                |     date, signature
    |                                                |
    |== 6. encrypted: kubectl get pods =============>|
    |                                                |
    |                                                |  7. RBAC: user
    |                                                |     satyaki, group
    |                                                |     devops
  1. Hello. kubectl reads the server address and the three files from your kubeconfig, and opens a connection.
  2. The server proves itself. It sends apiserver.crt plus a fresh signature made with apiserver.key, then asks for your certificate. The key itself never leaves the server; only the signature does.
  3. kubectl checks the server. Stamp with ca.crt, name against the server address, date, and the signature with the public key inside apiserver.crt. If anything fails, kubectl hangs up here and sends nothing of yours.
  4. You prove yourself. kubectl sends me.crt plus a fresh signature made with me.key.
  5. The server checks you. Stamp with its own ca.crt, date, and the signature with the public key inside me.crt.
  6. Encrypted traffic. Your command travels encrypted with the session key built during steps 1–5.
  7. RBAC decides. The server reads your certificate: CN=satyaki becomes the user, O=devops the group.

What fails where

What went wrong Stops at What you see
Wrong or missing ca.crt in kubeconfig Step 3, stamp x509: certificate signed by unknown authority
Server address not listed in apiserver.crt Step 3, name x509: certificate is valid for X, not Y
Fake server with a copy of apiserver.crt Step 3, key kubectl hangs up
Fake server with its own cert for the same name Step 3, stamp x509: certificate signed by unknown authority
A client cert signed by another CA Step 5, stamp error: You must be logged in to the server (Unauthorized)
Everything valid, but no RBAC rule for you Step 7 Error from server (Forbidden): ... User "satyaki" cannot ...

7. EKS: same server check, a token instead of a client certificate

On EKS, AWS runs the control plane and the cluster CA. Steps 1 to 3 are exactly the same. Steps 4 and 5 are replaced by a token, so there's no me.crt and no me.key. Strictly speaking, logging in to EKS is TLS plus a token, not mTLS.

 1. kubectl runs `aws eks get-token`
      the AWS CLI signs a "who am I?" request with your AWS credentials
      that signed request IS the token (k8s-aws-v1..., ~15 minutes)
      your secret key is not inside it

 2. kubectl --TLS--> EKS endpoint
      EKS proves itself; kubectl checks it with certificate-authority-data
      (steps 1 to 3 above, unchanged)

 3. kubectl --"Authorization: Bearer k8s-aws-v1..."--> EKS
      sent inside the encrypted connection

 4. EKS --"who signed this?"--> AWS STS
      STS: arn:aws:sts::123456789012:assumed-role/DevOps/satyaki

 5. access entry: that ARN -> Kubernetes user + groups -> RBAC
Job Plain Kubernetes EKS
Prove the server apiserver.crt, checked with ca.crt Same, checked with certificate-authority-data
Your ID me.crt, signed by the cluster CA Your IAM identity, confirmed by AWS STS
Prove it's you Fresh signature made with me.key Token signed with your AWS credentials
Becomes user + groups CN and O in me.crt Access entry (older clusters: aws-auth ConfigMap)
Lasts Usually a year About 15 minutes

Keep this in mind for later: the server half is identical on EKS. That's the half Zscaler breaks.

8. Enter Zscaler: one connection becomes two

The Zscaler app on your Mac (Zscaler Client Connector) sends your traffic through Zscaler's cloud. For each site, IT's policy picks one of two treatments.

 DO NOT INSPECT (bypass)                                kubectl works

   kubectl ========== one TLS connection ========== EKS
                  Zscaler passes it through untouched
                  and only sees the site's name


 INSPECTED                                              kubectl fails

   kubectl ======= #1 ======= Zscaler ======= #2 ======= EKS
            Zscaler's own cert           the real EKS cert
            (Zscaler is the SERVER)      (Zscaler is the CLIENT)

With inspection there are two separate TLS connections. Here's how Zscaler builds connection #1, for any site:

  1. Your client says hello and names the site it wants. That name (SNI) is sent in plain text, so Zscaler can read it.
  2. Connection #2: Zscaler connects to the real site as a client, receives the real certificate, and checks it against its own list of public root CAs, just like a browser would.
  3. Zscaler makes a new certificate on the spot with the same names, a new key pair, and signs it with its own intermediate CA, for example Zscaler Intermediate Root CA (zscalerthree.net) (t). That intermediate rotates weekly, which is why these certificates expire within about a week.
  4. Connection #1: Zscaler sends that certificate to your client, with a fresh signature made with the new key.

Now run the four checks on that certificate:

 Name:  pass   (Zscaler copied the real site's names)
 Date:  pass
 Key:   pass   (Zscaler holds the key for the cert it just made)
 Stamp: ????   (signed by Zscaler's CA, so: does your client trust it?)

It's the "own cert for the same name" row from section 4. Anyone with a CA can write any name into a certificate, so the name proves nothing by itself. It only counts when a CA you trust signed it.

Where does the trust come from? IT installs the Zscaler Root CA certificate into your Mac's keychain. Zscaler keeps the matching private key in its cloud. It's the same setup as your cluster:

Kubernetes Zscaler
ca.key signs certs (stays on the control plane) Zscaler's CA key signs certs (stays in Zscaler's cloud)
ca.crt in your kubeconfig checks them Zscaler Root CA in your keychain checks them
apiserver.crt is the server's ID The cert Zscaler makes on the spot replaces the server's ID
kubectl does the checking Your browser does the checking

Note that Zscaler's certificate replaces the server's certificate. It has nothing to do with your client certificate (me.crt).

9. Why the browser works and kubectl doesn't

Every app runs the same four checks. What differs is which list of trusted CAs each app uses for the stamp check.

App Trusts Zscaler root in it? When inspected
Safari, Chrome, Edge, Brave The Mac keychain Yes, IT added it Works
Firefox Its own list, plus the keychain when "Allow Firefox to automatically trust third-party root certificates you install" is on (default since Firefox 120) Only if that's on Warning page if off
AWS CLI Its own bundled list No SSL validation failed
kubectl Only certificate-authority-data from your kubeconfig. It ignores the keychain. No Fails

That's the whole mystery in one table. Your browser trusts Zscaler's CA. kubectl deliberately trusts exactly one CA: your cluster's.

10. Exactly where kubectl breaks

On EKS, kubectl can fail in two places, and both come from inspection.

A. Making the token. To make a token, the AWS CLI sometimes has to reach AWS to refresh your SSO credentials. If Zscaler inspects that and the AWS CLI doesn't trust the Zscaler root, you get SSL validation failed ... certificate verify failed, and kubectl reports:

getting credentials: exec: executable aws failed with exit code 255

B. Connecting to EKS.

 kubectl ===== #1 ===== Zscaler ===== #2 ===== EKS

 #2  Zscaler checks the EKS cert
     signed by your cluster's PRIVATE CA (CN=kubernetes)
     not on any public list, so Zscaler treats it as untrusted
     -> depending on IT's policy, Zscaler blocks it:
        "connection reset by peer"

 #1  if it gets this far, kubectl checks Zscaler's cert
     with certificate-authority-data only
     -> stamp check fails:
        "x509: certificate signed by unknown authority"

Either way kubectl stops at step 3, before your token is ever sent.

"Why doesn't Zscaler just forward the real certificate?"

It could forward the certificate, since it's public. But then it would also have to sign kubectl's handshake with the EKS server's private key, which it doesn't have, so the key check would fail.

The only way to give kubectl the real certificate and a valid signature is to forward EKS's own handshake untouched. Then Zscaler can't read anything, because the session key is built between kubectl and EKS. That is exactly what Do Not Inspect means.

And with client certificates (plain Kubernetes)?

It could never work through inspection, not even in theory. On connection #2, Zscaler would have to prove it's you (step 4). It can copy me.crt, which is public, but it doesn't have me.key. That's mTLS doing its job: nobody in the middle can pretend to be either side.

Tempting, but wrong: put the Zscaler root in your kubeconfig

Connection #1 would then pass the stamp check. But:

  1. Connection #2 still fails. Zscaler still can't verify your cluster's private CA.
  2. If IT's policy lets it through anyway, nobody is checking EKS. kubectl trusts Zscaler, Zscaler can't verify the cluster, and a fake EKS endpoint would be accepted.
  3. Your token gets exposed. Zscaler decrypts connection #1, so your bearer token is readable there, and it's valid for about 15 minutes.
  4. It breaks elsewhere. Off the corporate network, or once the bypass is in place, the real EKS certificate isn't signed by Zscaler.

The same goes for --insecure-skip-tls-verify. certificate-authority-data is there to pin kubectl's trust to exactly one CA. Keep it that way.

11. The fix

For kubectl: ask IT for a Zscaler Do Not Inspect (SSL bypass) rule for *.eks.amazonaws.com. Traffic still goes through Zscaler, and Zscaler still sees the site name, so it can still allow or block the site. It just doesn't decrypt. You're back to one connection and the real EKS certificate.

For the AWS CLI: either the same bypass for *.amazonaws.com, or give the AWS CLI a CA list that also includes the Zscaler root. Keep the public CAs in the list, so AWS calls work whether Zscaler inspects them or not:

security find-certificate -a -c Zscaler -p > ~/zscaler-root.pem
cat /etc/ssl/cert.pem ~/zscaler-root.pem > ~/ca-bundle-zscaler.pem
echo 'export AWS_CA_BUNDLE="$HOME/ca-bundle-zscaler.pem"' >> ~/.zshrc

To check whether the bypass works, look at who signed the certificate your laptop actually receives from EKS:

EKS=$(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}' | sed 's#https://##')
openssl s_client -connect "$EKS:443" -servername "$EKS" </dev/null 2>/dev/null \
  | openssl x509 -noout -issuer
  • issuer=CN=kubernetes: the bypass works. That's your cluster's CA, so kubectl will connect.
  • An issuer that mentions Zscaler: the connection is still being inspected.
  • An error and no issuer: Zscaler is dropping the connection.

12. Bonus: when the browser breaks too

The same mechanism breaks browsers too. A typical case: a handful of sites stop opening in Chrome with NET::ERR_CERT_AUTHORITY_INVALID. Clicking the error code shows:

net::ERR_CERT_AUTHORITY_INVALID
Subject: us-east-1.signin.aws
Issuer: Zscaler Intermediate Root CA (zscalerthree.net) (t)
Expires on: 6 Dec 2026
Current date: 28 Nov 2026

Read it like a detective:

  • The issuer is Zscaler, so this site is inspected and the certificate was made by Zscaler on the spot.
  • It expires in a week, which matches Zscaler's weekly intermediate.
  • AUTHORITY_INVALID means the stamp check failed.

Where it fails is exactly the kubectl story, with the browser as the client:

 1. browser: hello, us-east-1.signin.aws      -> Zscaler catches it
 2. #2: Zscaler <-> AWS, real cert, public CA -> passes
 3. #1: Zscaler sends its own cert for that name
 4. browser checks it:
      name  pass
      date  pass
      key   pass
      stamp FAIL   (can't trace it to a Zscaler root it trusts)
 5. browser hangs up

Your actual request (the page, cookies, a password) is never sent. The check fails safely.

Why only a few sites? Only inspected sites get a Zscaler certificate. Bypassed sites show their real certificate, signed by a public CA the keychain already trusts.

How to narrow it down:

  1. Is the Zscaler root in the keychain, and trusted? Installed isn't the same as trusted. A certificate you add by hand isn't trusted until you set Always Trust. In Keychain Access, look under System for the Zscaler Root CA, and check it's set to Always Trust.
  2. Does the same site open in Safari? Safari uses the same keychain. If it opens there, the chain and the root are fine and the problem is in Chrome only.
  3. If it's Chrome only:
    • Quit Chrome fully with Cmd+Q. Chrome keeps trust decisions and intermediates in memory.
    • Try an Incognito window, to rule out extensions.
    • Look in chrome://policy for certificate policies, such as CAPlatformIntegrationEnabled set to false, which makes Chrome ignore roots added to the keychain.
    • Compare "Issued By" in Chrome and Safari. If they differ, Chrome is reaching the internet a different way.

The four things that look like "blocked" in a browser:

What you see What's happening
Certificate warning, issuer is Zscaler, every inspected site fails in that browser The browser doesn't trust the Zscaler root (keychain trust, or the Firefox setting)
Other Zscaler-issued sites load fine, but one site fails Zscaler's own check of that site on connection #2 failed (expired, self-signed or private CA)
A Zscaler-branded "blocked" page Company policy for that kind of site. Certificates are fine.
A site or app that fails only while inspected (client-certificate logins, apps that pin their certificate) It needs the real, unsplit connection, just like kubectl. Ask for Do Not Inspect.

Cheat sheet

You see What failed Usual cause
x509: certificate signed by unknown authority Stamp check Wrong CA in kubeconfig, or Zscaler inspecting
x509: certificate is valid for X, not Y Name check Connecting by an address that isn't in the cert
x509: certificate has expired or is not yet valid Date check Renew the cert, or fix the machine's clock
connection reset by peer (to EKS, behind Zscaler) Zscaler blocked connection #2 Needs Do Not Inspect
getting credentials: exec: executable aws failed The AWS CLI behind inspection AWS_CA_BUNDLE, or bypass *.amazonaws.com
You must be logged in to the server (Unauthorized) Your proof Client cert from the wrong CA, or an expired token
Error from server (Forbidden) RBAC TLS was fine. You lack permissions.
NET::ERR_CERT_AUTHORITY_INVALID, issuer Zscaler The browser's stamp check The browser doesn't trust the Zscaler root

TL;DR

  • A certificate is a public ID card. The private key proves it's yours. The CA certificate checks the stamp.
  • There are two signatures: ca.key stamps the certificate once, and the owner's private key signs every handshake. You need both, because certificates are public and anyone can copy one.
  • Every client runs four checks: stamp, name, date, key. Every TLS error is one of them failing.
  • Zscaler inspection splits one connection into two and re-signs it with its own CA. Browsers trust that CA. kubectl trusts only your cluster's CA, by design.
  • The fix is a Do Not Inspect rule for *.eks.amazonaws.com. Don't put Zscaler's root in your kubeconfig.

Every section in this post started as a question I asked while untangling this. If something still doesn't click, ask in the comments.

πŸ“° Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β€” full credit and traffic to the original publisher.