Kafka's bootstrap address is only an introduction. After connecting, a producer or consumer receives broker metadata and establishes connections to the advertised brokers. That makes advertised.listeners part of the certificate design. A single trusted bootstrap hostname cannot compensate for metadata containing private container names, wrong ports, or broker names absent from certificate SANs.
This guide targets Apache Kafka 4.1.x in a self-managed KRaft deployment with an existing working controller quorum. It adds a named external TLS listener and leaves the existing controller and inter-broker security design intact. The examples use Java clients and PKCS12 stores, not a distribution-specific environment-variable wrapper. They are reviewed configuration examples, not a claim that a cluster or issuance flow has been tested.
Step 1: Map metadata addresses before creating certificates
Write down the address that a remote client must use for every broker. For a three-broker example, use kafka1.example.com, kafka2.example.com, and kafka3.example.com, each reachable on 9093. Resolve them from the actual producer and consumer networks. If those networks differ, plan separate listener names and certificate coverage instead of assuming every client sees the same topology.
A container may listen on 0.0.0.0 while advertising a stable DNS name; those values intentionally serve different purposes. The wildcard bind address is a socket choice, not a certificate identity, and must not be advertised as an endpoint. Similarly, a Docker service name may be correct for internal traffic yet meaningless to an application outside that Docker network.
Record your current listeners, listener.security.protocol.map, inter.broker.listener.name, controller.listener.names, and quorum configuration before touching the file. In KRaft, controller communication is not the same as an external client listener. Replacing an entire example server.properties file can break the quorum even when the new TLS listener itself is valid. Keep the change to the intended listener and preserve the tested internal settings.
Choose certificate names per broker. Individual leaf certificates and keys make ownership and rotation easier to audit. A wildcard may cover a consistent broker naming scheme, but it does not cover a different namespace or authenticate a private IP. Keep a document that pairs each advertised DNS name with its certificate lineage, deployment path, broker ID, and client-facing port.
Step 2: Obtain server certificates without giving Kafka DNS authority
Precreate each needed registration in SimpleACME, add the assigned permanent challenge CNAME, and activate paid update access. Your normal authoritative DNS host stays in place. The ACME renewal host uses the delegated update credential for validation; it does not need the broader DNS provider API credential merely to prove control of the certificate hostname.
Use the public Certbot guide and subscriber Certbot configuration to set up issuance with a supported client. Kafka does not gain a native SimpleACME plugin from this arrangement. The ACME client issues and renews, and your deployment process converts the resulting files into the format Kafka consumes. SimpleACME supplies paid delegated TXT updates, not broker configuration or certificate installation.
Run issuance separately from the brokers where practical. A controlled deployment identity can deliver each broker's own materials without placing challenge credentials in every Kafka container. Do not copy one broad credential bundle everywhere simply because a wildcard is available. Inventory who can read private keys and who can alter advertised addresses; both capabilities affect the identity that clients ultimately trust.
Test against a staging CA before using production issuance, but never distribute a staging certificate to production clients as a trusted public certificate. Keep staging outputs and production outputs in different paths. A successful staging challenge establishes the validation route, not that your Java trust store will accept a production chain or that Kafka can open the generated PKCS12 file.
Step 3: Build a keystore and a deliberate truststore
Create a PKCS12 keystore containing the broker private key, leaf certificate, and intermediate chain. Use a protected password input and ensure the resulting store has a single intended private-key entry. Inspect it with keytool before deployment. A file that contains only a certificate is not a server keystore, even if its filename ends in p12.
umask 077
openssl pkcs12 -export -name kafka1 \
-inkey /secure/kafka1/privkey.pem \
-in /secure/kafka1/cert.pem \
-certfile /secure/kafka1/chain.pem \
-out /secure/stage/kafka1.p12
keytool -list -v -storetype PKCS12 \
-keystore /secure/stage/kafka1.p12The truststore answers a different question: which issuing CAs should this Kafka component trust when it acts as a TLS client or verifies a client certificate? Import the deliberately selected trust anchor, verify its fingerprint through an approved source, and name the alias clearly. Do not import an arbitrary downloaded leaf certificate and accidentally create a fragile single-renewal trust relationship.
keytool -importcert -alias approved-root \
-file /secure/approved-root.pem \
-storetype PKCS12 -keystore /secure/stage/truststore.p12Keep keystore passwords out of Git, shell history, screenshots, and world-readable configuration. Kafka supports configuration-provider mechanisms in suitable deployments; use your established secret handling rather than inventing one during a TLS rollout. Restrict file permissions to the broker service identity. A password on a store is not a substitute for access control over both the store and the password file.
Step 4: Add a named listener while preserving the quorum
The fragment below illustrates broker one. Merge it with your existing properties and retain all current listener mappings required for controller and inter-broker communication. The placeholder password must be supplied using your approved configuration process. Set the corresponding hostname on each broker rather than copying kafka1's advertised identity throughout the cluster.
# Merge with existing listeners and protocol mappings.
listeners=EXTERNAL://0.0.0.0:9093,INTERNAL://0.0.0.0:9092
advertised.listeners=EXTERNAL://kafka1.example.com:9093,INTERNAL://kafka1.internal.example.com:9092
listener.security.protocol.map=EXTERNAL:SSL,INTERNAL:SSL,CONTROLLER:SSL
listener.name.external.ssl.keystore.type=PKCS12
listener.name.external.ssl.keystore.location=/etc/kafka/tls/kafka1.p12
listener.name.external.ssl.keystore.password=REPLACE_WITH_SECRET
listener.name.external.ssl.key.password=REPLACE_WITH_SECRET
listener.name.external.ssl.client.auth=none
# Preserve configured controller listener/quorum and internal TLS settings.This is not a complete combined broker/controller configuration. A combined-role node also needs its controller listener in listeners and the associated settings; a broker-only node follows its existing KRaft topology. The snippet intentionally does not choose node IDs, quorum voters, controller ports, storage paths, or cluster authentication for you. Review those as part of the effective configuration before restarting anything.
SSL encrypts and identifies the server, but it is not automatically a complete client authorization policy. The example's client.auth=none does not present mutual TLS identity. If your application security requires authenticated users, use your established SASL_SSL or client-certificate design and Kafka ACLs. Do not replace an authenticated listener with anonymous SSL simply because the network probe succeeds.
Step 5: Inspect metadata and perform a limited client transaction
Create a protected client.properties file with the intended security protocol and trust settings. Keep hostname verification enabled. For a private CA, provide the selected truststore; a public CA chain still needs to be trusted by the JDK actually running the client. A workstation browser's trust decisions do not establish what an old Java runtime trusts.
security.protocol=SSL
ssl.truststore.type=PKCS12
ssl.truststore.location=/secure/client/truststore.p12
ssl.truststore.password=REPLACE_WITH_SECRET
ssl.endpoint.identification.algorithm=httpsbin/kafka-broker-api-versions.sh \
--bootstrap-server kafka1.example.com:9093 \
--command-config /secure/client/client.properties
openssl s_client -connect kafka2.example.com:9093 \
-servername kafka2.example.com -verify_hostname kafka2.example.com \
-verify_return_error </dev/nullCheck every returned broker endpoint, then use a dedicated test topic and least-privilege test principal to produce and consume a recognizable record. Record which partitions and brokers were exercised. A single bootstrap success can leave a bad certificate on another broker undiscovered until leadership changes. Test from outside the broker network if that is where the real application lives.
If failures appear only after metadata arrives, investigate the advertised hostname, its routing, and certificate coverage. Do not erase ssl.endpoint.identification.algorithm to suppress verification. That turns a discoverability or identity defect into silent acceptance of the wrong endpoint. A diagnosis should identify whether the failure is TCP reachability, trust chain, SAN mismatch, store password, or application authorization.
Step 6: Rotate one broker generation at a time
Renewal deploys more than new PEM files: the PKCS12 store must be rebuilt, inspected, given correct permissions, and loaded by Kafka. Some SSL properties support dynamic reconfiguration in supported releases, but do not assume every store and listener change is reloadable in your packaging. A documented rolling restart is a conservative plan when dynamic behavior has not been verified.
Preserve quorum and partition availability. Check under-replicated partitions and in-sync replicas before taking a broker down, bring it back healthy, and only then proceed. Retain the prior keystore, truststore, passwords, and listener properties as one rollback generation. Restoring a store while leaving its new password in configuration is not a rollback.
After deployment, open fresh client connections and compare the served certificate's identity and expiry. Monitor clients that maintain long-lived connections; their continued traffic alone does not prove the renewed certificate is usable. Schedule a renewal deployment rehearsal before expiry pressure makes the first real rotation urgent. Track challenge success, keystore generation, broker activation, and application transactions as separate outcomes.
Diagnose a failed listener by the stage it reached
A useful incident note starts with the last successful stage. If TCP never connected, inspect routing, firewall rules, and port publishing before rebuilding a keystore. If the TLS handshake rejected the chain, inspect the client's actual JDK trust source and the chain served by that broker. If TLS succeeded but the client could not authenticate, inspect the chosen SASL or mutual-TLS design rather than changing certificate names.
If a producer obtained metadata and then stopped making progress, compare the returned broker addresses with the endpoints you tested. A partition leader on an untested broker can expose a listener defect that a bootstrap-only check missed. Use a controlled topic and record its leaders so the result is reproducible without dumping business records into diagnostic output.
Finally, distinguish a certificate rotation from a CA rotation. Replacing a leaf under an already trusted chain is generally a smaller client-trust change than introducing a new trust anchor. When changing issuers or private roots, plan overlapping trust distribution before broker activation. Do not discover during expiry recovery that one consumer image ships a frozen truststore nobody has owned for years.
Frequently asked questions
Why does bootstrap work but producers time out afterward?
The metadata may advertise unreachable names or names that the certificates do not cover. Test each advertised broker from the producer network. Fix advertised.listeners and SAN coverage together rather than assuming the seed address is the only connection target.
Can I use PEM directly instead of PKCS12?
Supported Kafka releases offer PEM configuration options, but those have their own property and key-format requirements. This guide deliberately chooses PKCS12 for a Java-oriented operational workflow. Do not mix PEM property names with PKCS12 stores or assume a distribution wrapper accepts the same inputs.
Does a wildcard certificate secure the KRaft controller automatically?
No. Controller and inter-broker listeners remain separate configuration and trust boundaries. The certificate's name coverage does not turn on TLS for another listener or authorize a node to join the quorum. Preserve and audit the internal security design independently.
Does SimpleACME prove Kafka renewed successfully?
It records delegated DNS update activity. Your ACME client must issue, your deployment process must build and activate the store, and fresh Kafka clients must verify the result. Only those combined observations establish a working renewal deployment.
Official references
Kafka 4.1 SSL encryption and authentication describes store-based TLS. Kafka 4.1 broker configuration defines listener and SSL properties. Use the version selector when your deployed Kafka release differs.