Repository navigation
[fix][broker] Request TLS client certificates only when they are required or used - #27046
Merged
Merged
Conversation
…ired or used Pulsar TLS servers always requested a client certificate, and the TLS CertificateRequest lists every CA in the server's trust store, or all ~150 JVM default CAs (about 16 KB of names) when no trust file is configured. With a large bundle the TLS 1.3 server flight exceeds one 16 KB TLS record, which some clients fail to handle, even in deployments that never authenticate clients by certificate. Add tlsClientAuthMode (NONE, OPTIONAL, REQUIRE) to the broker, proxy, websocket proxy and functions worker. When unset, it is REQUIRE if the now deprecated tlsRequireTrustedClientCertOnConnect is true, OPTIONAL if authentication is enabled with AuthenticationProviderTls, and NONE otherwise, so no certificate is requested when nothing requires or uses one. Add tlsClientAuthTrustCertsFilePath and tlsClientAuthTrustStore (with type and password) to validate client certificates against dedicated CAs, such as a private client CA, while tlsTrustCertsFilePath keeps serving outbound connections. Public CAs are removing the clientAuth extended key usage from their TLS certificates, so the client-auth trust anchors should not be a public CA bundle. Assisted-by: Claude Code (claude-opus-5-5)
lhotari
requested review from
Technoboy-,
codelipenghui,
dao-jun,
merlimat and
nodece
October 22, 2026 12:08
lhotari
marked this pull request as draft
October 22, 2026 20:05
…E with TLS auth - Remove tlsClientAuthTrustCertsFilePath and the tlsClientAuthTrustStore* keys and helpers. The server listeners validate client certificates against tlsTrustCertsFilePath / tlsTrustStore as before; separating them from outbound trust is a follow-up. - Reject an explicit tlsClientAuthMode=NONE while AuthenticationProviderTls is enabled. - Log the effective mode and its source once per component that has a TLS listener. - PulsarFunctionTlsTest: configure the worker's own authenticationProviders, as a real worker does. Assisted-by: Claude Code (claude-opus-5-5)
codelipenghui
approved these changes
Nov 9, 2026
dao-jun
approved these changes
Nov 10, 2026
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
Nov 26, 2026
…ired or used (apache#27046) (cherry picked from commit deac87c)
poorbarcode
pushed a commit
to poorbarcode/pulsar
that referenced
this pull request
Nov 26, 2026
…ired or used (apache#27046) (cherry picked from commit deac87c)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #27036
Motivation
Pulsar TLS servers (broker, proxy, websocket proxy, functions worker; binary and web listeners) always requested a
client certificate.
tlsRequireTrustedClientCertOnConnect=falseonly downgraded "require" to "want". Each TLSCertificateRequestcarries the names of every trust anchor incertificate_authorities:tlsTrustCertsFilePathpointing at an operating-system CA bundle (~120 CAs), theCertificateRequestisabout 16 KB. The TLS 1.3 server flight (
EncryptedExtensions+CertificateRequest+Certificate+CertificateVerify+Finished) then spans two TLS records. That is valid TLS, but some clients mishandle it:a .NET client on Windows stopped connecting after a base-image CA bundle update added two CAs. No error was
logged by the broker or the proxy.
cacertshas 146 CAs,15,734 bytes of names.
This happened in deployments that never authenticate clients by certificate (token or OAuth 2.0 only), where
requesting a client certificate serves no purpose.
Modifications
New
tlsClientAuthModesetting (NONE,OPTIONAL,REQUIRE) on the broker, proxy, websocket proxy andfunctions worker (
TlsClientAuthModeinpulsar-common). It applies to all TLS listeners, binary and web.When unset, it is resolved for compatibility as follows:
REQUIREiftlsRequireTrustedClientCertOnConnect=true;OPTIONALifauthenticationEnabled=trueandAuthenticationProviderTls(or a subclass) is among theauthenticationProviders;NONEotherwise: noCertificateRequestis sent.Two combinations are rejected at startup:
tlsRequireTrustedClientCertOnConnect=truewith an explicitNONEorOPTIONAL, and an explicitNONEwhileAuthenticationProviderTlsis enabled (TLS authentication could neversucceed).
Each component with a TLS listener logs the effective mode once at startup, with where it came from, e.g.
TLS client auth mode {component=broker, mode=NONE, source=derived: AuthenticationProviderTls not among authenticationProviders}.tlsRequireTrustedClientCertOnConnectis deprecated in favor oftlsClientAuthMode=REQUIRE. It is kept inevery conf file that had it, so environment-variable overrides keep working. The new TLS factory APIs take only
the mode:
FileBasedTlsFactorySettings.Builder.clientAuthMode,TlsSynthesisSpec.server,JettyTlsFactory.createReloadingServerFactory, and theTlsContextsbuilders.All server consumers are wired:
PulsarChannelInitializer,DefaultBrokerTlsFactory) and web (WebService)ServiceChannelInitializer,ProxyTlsFactories) and web (WebServer)ProxyServerWorkerServerFor a custom
tlsFactoryClassName, the mode applies through the framework's Netty and Jetty synthesis paths.Config docs and conf files describe the new setting and the record-size interaction: when a certificate is
requested, the
CertificateRequestlists every CA intlsTrustCertsFilePath/tlsTrustStore, so that truststore should hold only the CAs that issue client certificates. Two PIP-478 references to the deprecated flag now
name
tlsClientAuthMode=OPTIONAL.The trust anchors used for validating client certificates are unchanged (
tlsTrustCertsFilePath/tlsTrustStore). Separating them from the outbound trust of function instances is left to a follow-up.Behavior change: with no configuration change, a TLS server that neither requires client certificates nor
authenticates with
AuthenticationProviderTlsno longer requests one. A custom authentication provider that readsthe client certificate must set
tlsClientAuthMode=OPTIONAL(orREQUIRE). A functions worker reads its ownauthenticationProviders, as itsAuthenticationServicealready does.Pulsar 4.x (the PIP-337
DefaultPulsarSslFactoryTLS path) needs a separate fix. It always requests a clientcertificate when
tlsRequireTrustedClientCertOnConnect=false(setWantClientAuth(true)), so the reported issueremains there until a 4.x change stops requesting client certificates when they are neither required nor used.
Verifying this change
This change added tests and can be verified as follows:
TlsClientAuthModeTestandTlsFactorySupportTestcover:AuthenticationProviderTls, including a subclass, an unknown class and authentication disabledFileBasedTlsFactoryTest(JDK and OpenSSL engines, TLS 1.2 and 1.3): a client key manager records what theserver asked for.
NONEsends noCertificateRequest, also in insecure mode and with the JVM default anchors.OPTIONALlists the trusted CA and captures the client certificate.REQUIRErejects a missing certificate.SslParametersSynthesisTestandJettyTlsFactoryTestcover the mode on the synthesized Netty and Jetty servercontexts.
settings.
TlsClientAuthModeBrokerTest(end to end): a real broker's binary and web TLS ports send noCertificateRequestby default and send one withtlsClientAuthMode=OPTIONAL.ClientAuthenticationTlsTest,TlsProducerConsumerTest,AuthenticatedProducerConsumerTest,ProxyWithAuthorizationTest,ProxyMutualTlsTest, theProxyKeyStoreTls*tests and bothPulsarFunctionTlsTests.OPTIONALin the broker'sWebServiceorDefaultBrokerTlsFactorywiring fails theend-to-end and policy tests.
Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
required or
AuthenticationProviderTlsis enabled;tlsRequireTrustedClientCertOnConnectis deprecated infavor of
tlsClientAuthModetlsClientAuthMode