Quick revision
The short answer
PKIX path building failed means the peer could not build a chain from the presented certificate to a CA it trusts, because the other brokers and clients did not yet trust the new intermediate's root, or the keystore did not include the intermediate in its chain. No subject alternative names matching means host name verification failed: the new certificate's SANs do not contain the advertised host name the peer connected to. A zero-downtime rotation adds the new CA to every truststore first, then replaces broker keystores one at a time with full chains and correct SANs, reloading them dynamically where possible, and removes the old CA only when nothing presents old certificates.
What to remember
In this answer, we saw that PKIX path building failed means a peer could not chain the presented certificate to a trusted CA, because of a CA not yet trusted or a missing intermediate, and that no subject alternative names matching means the certificate does not name the advertised host. Followers left the ISR because replication runs over the same TLS. A safe rotation distributes trust to everyone first, then replaces keystores one node at a time with full chains and correct SANs, using dynamic reloads where the version allows, and removes the old CA last, with expiry metrics and automation preventing a 10-day scramble.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
PKIX path building failed means the peer could not build a chain from the presented certificate to a CA it trusts, because the other brokers and clients did not yet trust the new intermediate's root, or the keystore did not include the intermediate in its chain. No subject alternative names matching means host name verification failed: the new certificate's SANs do not contain the advertised host name the peer connected to. A zero-downtime rotation adds the new CA to every truststore first, then replaces broker keystores one at a time with full chains and correct SANs, reloading them dynamically where possible, and removes the old CA only when nothing presents old certificates.
Why this question is asked
Certificate rotation is a planned change that regularly turns into an outage, because TLS fails closed: a certificate a peer does not trust is not a warning, it is a refused connection. The test cluster showed both classic mistakes at once, and with 10 days left on production certificates, the question is how to do it right. Interviewers ask this to see whether we understand TLS trust well enough to plan the order of changes. In this answer, we will recap how a certificate chain is checked, explain each error, see why followers dropped out of the ISR, plan the rotation in phases, reload certificates without restarts, and automate renewal so it never comes down to 10 days again.
1A Quick Recap: Keystores, Truststores and Chains
Each broker has a keystore with its private key and its certificate, and a truststore with the CAs it trusts. A certificate is usually signed by an intermediate CA, which is signed by a root CA. When a broker presents its certificate, it should send the whole chain, its own certificate plus the intermediate, so the peer can follow the signatures up to a root in its truststore. That process of building and checking the chain is what Java calls PKIX validation.
The peer then checks a second thing: the certificate must be for the host it connected to. The host names and IPs a certificate is valid for are listed in its subject alternative names, the SANs. With ssl.endpoint.identification.algorithm=https, Kafka's default, clients and brokers compare the address they connected to, which comes from advertised.listeners, with those SANs.
2Why the Two Errors Appeared
PKIX path building failed has two possible causes here. Either the peers did not trust the new CA, because the new intermediate chains to a root that is not in their truststores yet, or the root was trusted but the broker's keystore held only its own certificate without the new intermediate, so the peer had no way to connect the certificate to the root. Both look the same from the outside. No subject alternative names matching is a separate failure: the chain was fine, but the new certificate was issued without the host name, or IP, that clients and brokers use for that broker.
The ISR drop follows directly. Replication runs over TLS on the inter-broker listener. Other brokers fetching from partitions led by the restarted broker, and the restarted broker fetching from others, failed their handshakes, so followers stopped making progress and were removed from the ISR after replica.lag.time.max.ms. We can confirm each cause from any machine.
So the test broker had both problems: an incomplete chain, and SANs that did not match the advertised name. Fixing the order of trust and the content of the certificate fixes both.
3Rotating Without Downtime: Trust First
The rule that makes rotation safe is that everyone must trust the new CA before anyone presents a certificate from it. So we work in phases, and each phase is fully rolled out and verified before the next starts.
- Add new CA to all truststoresbrokers, controllers, all clients
- Everyone trusts both CAs?YesStart keystore phaseNoKeep rolling out trust
- Replace one broker's keystorefull chain, SANs = advertised names
- ISR and client errors clean?YesNext brokerNoRoll that broker back
- Old certificates still in use?YesWaitNoRemove old CA from truststores
5 steps in order. Play them, or step through them one at a time.
Phase one changes only truststores: we add the new root, and the intermediate if we distribute it that way, next to the old one, on brokers, controllers and every client. Clients are the slow part, because 150 services must redeploy with the new truststore or pick up a new CA bundle, so this phase starts first and we track it per service. Phase two replaces broker and controller keystores with certificates from the new CA, each carrying the full chain and SANs for every advertised host name, one node at a time. Phase three removes the old CA from truststores, but only when no node or client presents an old certificate anymore, including client certificates for mutual TLS.
4Reloading Certificates Without Restarting
Brokers can reload keystores and truststores through dynamic configuration, so phase two does not need restarts. We update the listener-specific keystore location for one broker, which makes it load the new file and use it for new connections; existing connections keep working.
There is a catch. To prevent mistakes, Kafka may refuse a dynamic keystore update whose certificate changes the subject name or the SANs, unless ssl.allow.dn.changes or ssl.allow.san.changes is enabled; check your version. Since our new certificates deliberately fix the SANs, we either enable that setting for the rotation or do the keystore phase as a careful rolling restart. Either way, one broker at a time, checking ISR and client error rates in between.
5Automating Renewal
Ten days of notice is a process failure, not bad luck. We export the expiry date of every broker, controller and client certificate as a metric, alert at 30 days and page at 14, and issue certificates with automation, for example cert-manager on Kubernetes or a PKI service with an API, so renewal is routine. The full rotation, including a CA change, is rehearsed in a staging cluster with the same client mix, which is exactly what the test team just did, and it found two real problems before production.
6Follow-up questions
Why did followers leave the ISR instead of the broker just failing?
The broker process was healthy, but replication traffic between it and the other brokers could not complete TLS handshakes. Followers that cannot fetch fall behind, and after replica.lag.time.max.ms the leader removes them from the ISR.
Can we just put the new certificate in place and restart all brokers quickly?
No. Until every client trusts the new CA, every client connection to a broker with the new certificate fails, and restarting all brokers at once turns that into a full outage. Trust must be distributed first.
Does the order differ for mutual TLS client certificates?
The same rule applies in the other direction: brokers must trust the CA of new client certificates before clients start presenting them, and if principals are mapped from the certificate subject, the mapping rules must produce the same principal, or ACLs stop matching.
7Conclusion
In this answer, we saw that PKIX path building failed means a peer could not chain the presented certificate to a trusted CA, because of a CA not yet trusted or a missing intermediate, and that no subject alternative names matching means the certificate does not name the advertised host. Followers left the ISR because replication runs over the same TLS. A safe rotation distributes trust to everyone first, then replaces keystores one node at a time with full chains and correct SANs, using dynamic reloads where the version allows, and removes the old CA last, with expiry metrics and automation preventing a 10-day scramble.
Open with
There are two separate failures. PKIX path building failed means the peer could not build a chain from the certificate to a CA it trusts. Either the other brokers and clients did not trust the new CA yet, or the keystore only held the broker's own certificate without the new intermediate, so nobody could link it to the root.
Then, if they want more
No subject alternative names matching is host name verification: with the default ssl.endpoint.identification.algorithm https, the peer checks that the address it connected to, the advertised listener, is in the certificate's SANs, and the new certificate did not include it. Replication runs over TLS too, so the followers could not fetch and dropped out of the ISR.
I can confirm both with openssl s_client showcerts and by printing the SANs. For production I would rotate in phases. First add the new CA to every truststore, brokers, controllers and all clients, next to the old one, and track that per service.
Then replace broker keystores one at a time with the full chain and correct SANs, using dynamic config to reload the listener keystore, or a rolling restart if Kafka refuses a SAN change dynamically, checking ISR and client errors between brokers. Only when nothing presents old certificates do I remove the old CA.
Afterwards I would export certificate expiry as a metric and automate renewal so we never get down to 10 days again.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Kafka documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "In a test cluster a team replaced one broker's keystore with a certificate signed by a...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-operations/a137557955/