Repository navigation
Conversation
…TTPS is enabled bin/solr now reuses Solr's own keystore/truststore to make the embedded ZooKeeper TLS-only whenever SOLR_SSL_ENABLED=true and Solr is starting its own embedded ZooKeeper (no -z/--zk-host). The matching zookeeper.ssl.*/zookeeper.client.secure flags are persisted into the include file as SOLR_ZK_TLS_OPTS so co-located nodes and bin/solr zk/auth commands inherit them automatically. This has no effect on an external ZooKeeper ensemble, which must be secured independently. bin/solr.cmd (Windows) prints a warning instead, since it isn't supported there. SolrZkServer.java is fixed to honor a secureClientPort-only zoo.cfg instead of always defaulting a plaintext clientPort. The bin/solr start -e secure example and tutorial now rely on this automatic behavior instead of hand-rolling the same TLS setup themselves. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
|
Automated PR readiness judgements (LLM-generated; may be wrong; not updated on later pushes).
|
…d ZooKeeper ZookeeperStatusHandler.getZkRawResponse always opened a plaintext java.net.Socket to send its four-letter-word commands (ruok/mntr/conf). Against the now TLS-only embedded ZooKeeper (from the automatic SOLR-18527 TLS work), this broke the Admin UI's ZK status page. Reuse ZooKeeper's own ClientX509Util to open an SSLSocket instead, whenever -Dzookeeper.client.secure=true, building its SSLContext from the same zookeeper.ssl.* system properties already configured for the regular ZooKeeper client. No AdminServer migration needed. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
|
double check that " Contents of zookeeper /security.json are world-readable; consider setting up ACLs as described in https://solr.apache.org/guide/solr/latest/deployment-guide/zookeeper-access-control.html |
Can't verify a Windows batch script change without a Windows environment to test it on, and the behavior was already unchanged there (embedded ZK just stays plaintext, same as before this branch). Revert solr.cmd to its pre-SOLR-18527 state and drop the now-inaccurate changelog mention of a printed warning. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
The log.info(...) call for the embedded ZK startup message is already guarded by if (log.isInfoEnabled()), but the validator only looks at the single line immediately before the log call, which here is the InetSocketAddress clientAddress = getClientAddress(); assignment, not the if itself. Add the validator's own documented // nowarn escape hatch rather than restructuring working, correctly-guarded code. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
getZkRawResponse calls createSecureSocket up to 3x per ZK host (ruok, mntr, conf), and getZkStatus loops that over every host in the ensemble, so each admin-UI status check was rebuilding a fresh SSLContext (re-reading and re-parsing the truststore) for every single socket. Cache it as a lazily-initialized instance field instead, and close it from the handler's own close() (already inherited from SolrMetricProducer via RequestHandlerBase). Also simplify a zookeeper.client.secure boolean-property read down to the existing EnvUtils.getPropertyAsBool helper, matching the idiom already used elsewhere (NodeRoles.java, SolrZkServer.java) instead of a manual String default + Boolean.parseBoolean round-trip. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
This follow-on work is now tracked under SOLR-18659 (SOLR-18527 is closed/merged for the base secure example), matching PR apache#5329's retitle. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
zookeeper-access-control.adoc never mentioned TLS at all, even though the tutorial it links to for deployment guidance now covers both ACLs and the automatic embedded-ZK TLS behavior together. Add: a scope clarification alongside the existing "not about ZooKeeper process-level security" note, a callout in the Examples section that SOLR_ZK_TLS_OPTS is a separate, bin/solr-managed sibling of SOLR_ZK_CREDS_AND_ACLS rather than something to fold into it, and a note that `bin/solr zk updateacls` needs the matching zookeeper.ssl.* flags too when the target ZooKeeper requires TLS. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
janhoy
left a comment
There was a problem hiding this comment.
Here is a review done by Claude Fable. I have not myself reviewed the entire PR, but have proof read the comments in this review batch.
🤖 First pass over the Java, security policy, test and doc changes; the details are inline. The one bigger question is on bin/solr: whether the zoo.cfg rewrite belongs in SolrZkServer.parseConfig() (or a small solr zk sub-command) rather than in each OS script, which would give bin\solr.cmd the same behaviour for free and leave only the client-side -D flags in shell. I'd like to settle that before going through the script-level details, which I'm holding for a second pass.
Worth stating in the PR itself that this does not secure ZK's quorum and election ports? (But that might be food for SOLR-18094)
| # an external ensemble (-z/--zk-host) is never touched by this: Solr has no way to | ||
| # know whether an external ensemble uses TLS, so nothing is assumed there. | ||
| ZK_SECURE_PORT=$((SOLR_PORT_LISTEN + 1000)) | ||
| ZK_ZOO_CFG="$SOLR_HOME/zoo.cfg" |
There was a problem hiding this comment.
Could this whole zoo.cfg rewrite move into SolrZkServer.parseConfig() instead of living in each OS script? I.e. not touch zoo.cfg at all, but add those props at parse time (if they are missing from zoo.cfg). It already injects clientPort, clientPortAddress, the server list and the 4lw whitelist, so setting secureClientPort plus the zookeeper.ssl.* properties there would need no file edits, no password files on disk, and would cover bin\solr.cmd for free.
The client side could follow the same principle: the node knows it is running a TLS-only embedded ZooKeeper, so ZkContainer can configure its own SolrZkClient for TLS in process, and SolrCLI already builds an SSL context from SOLR_SSL_* for HTTPS, so bin/solr zk …/auth could derive the ZooKeeper trust material from the same variables. Then the only thing left for the scripts, and the only thing persisted, is one explicit switch that this ZooKeeper speaks TLS (-Dzookeeper.client.secure=true), instead of the whole SOLR_ZK_TLS_OPTS flag list, and it should be scoped to the embedded ZooKeeper rather than to every -z from that install.
| return hostName + ":" + addr.getPort(); | ||
| } | ||
|
|
||
| private InetSocketAddress getClientAddress() { |
There was a problem hiding this comment.
🤖 getClientAddress() prefers the plaintext address when both ports are configured, while zookeeper.client.secure=true forces TLS, so Solr would advertise and dial the wrong port. Prefer the secure address when that flag is set.
| permission java.io.FilePermission "${javax.net.ssl.trustStore}", "read,readlink"; | ||
|
|
||
| permission java.io.FilePermission "${zookeeper.ssl.keyStore.location}", "read,readlink"; | ||
| permission java.io.FilePermission "${zookeeper.ssl.keyStore.passwordPath}", "read,readlink"; |
There was a problem hiding this comment.
🤖 zookeeper.ssl.keyStore.location and .passwordPath are never set as system properties (zoo.cfg only turns them into properties after the policy is loaded), so these entries expand-fail and are dropped. The grants that actually carry the server side are ${solr.jetty.keystore} and ${solr.solr.home}${/}-.
| @@ -0,0 +1,15 @@ | |||
| title: > | |||
There was a problem hiding this comment.
🤖 A changed default that turns an existing embedded ZooKeeper TLS-only on upgrade also deserves an entry in the upgrade notes; the changelog is not where operators look for that.
| assert_failure | ||
| assert_output --partial 'Timeout while waiting for Zookeeper Client to connect' | ||
|
|
||
| run env SOLR_INCLUDE=/dev/null SOLR_ZK_CREDS_AND_ACLS="$tls_opts" \ |
There was a problem hiding this comment.
🤖 Isn't passing the TLS flags through SOLR_ZK_CREDS_AND_ACLS what the new note in zookeeper-access-control.adoc tells users not to do? Alternative: SOLR_ZK_TLS_OPTS=?
| tail -3 "$SOLR_INCLUDE" | ||
| ---- | ||
|
|
||
| `secureClientPort` replaces the plain `clientPort` ZooKeeper would otherwise default to, and `client.portUnification=false` makes the port reject plaintext connections outright. |
There was a problem hiding this comment.
🤖 client.portUnification=false is already ZooKeeper's default; the port rejects plaintext because it is a secureClientPort, not because of that line.
| private Socket createSecureSocket(String host, int port) throws IOException { | ||
| try { | ||
| SSLSocket socket = x509Util().getDefaultSSLContextAndOptions().createSSLSocket(); | ||
| socket.connect(new InetSocketAddress(host, port)); |
There was a problem hiding this comment.
🤖 socket.connect() has no connect timeout and no setSoTimeout; the plaintext path had the same gap, but a stalled TLS handshake now hangs the admin request too. Also worth confirming SNI/endpoint identification applies on a createSSLSocket() + connect() socket.
| if (props.getProperty("clientPort") == null) { | ||
| String bindHost = EnvUtils.getProperty("solr.zookeeper.embedded.host", "127.0.0.1"); | ||
| boolean hasClientPort = props.getProperty("clientPort") != null; | ||
| boolean hasSecureClientPort = props.getProperty("secureClientPort") != null; |
There was a problem hiding this comment.
🤖 Design note, not a request for this PR: this secures only the client port of a single embedded ZooKeeper. The ensemble that SOLR-18094 (#2391) is heading for also needs quorum TLS on the peer and election ports (sslQuorum=true, ssl.quorum.keyStore.*/ssl.quorum.trustStore.*, ssl.quorum.hostnameVerification), which takes the same keystore, and SOLR_SSL_CHECK_PEER_NAME should map to ssl.hostnameVerification for both layers, or a dev cluster with per-node self-signed certificates fails the moment there are two nodes. One place that derives all of ZooKeeper TLS from Solr's SSL settings would keep that from being redone later; this method is that place.
Embedded ZooKeeper TLS is now set up in memory at startup from Solr's HTTPS settings, without rewriting zoo.cfg or the include file. Simplify the new ZooKeeper TLS code and tests, and fix the security policies so the Netty-based ZooKeeper TLS transport works under the security manager (JFR event registration, network-interface lookup, and the revocation-checking security property). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
Simplify the secure example's and tutorial's ZooKeeper ACL step to match. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
NodeConfig no longer runs its startup ZooKeeper check when this node starts the embedded ZooKeeper itself. The secure example and tutorial now pass the /solr chroot with -DzkHost instead of editing solr.xml. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm
| + password | ||
| + " (used for the keystore and all basic-auth/ZooKeeper demonstration accounts below)."); | ||
| echo("ZooKeeper is protected by digest ACLs; its transport remains plaintext on loopback."); | ||
| if (!params.noPrompt()) { |
There was a problem hiding this comment.
🤖 AI text below 🤖
Dropping this prompt makes an interactive secure run delete the selected Solr home immediately, including an existing home passed with --solr-home. Can the prompt stay unless the caller passes --no-prompt?
| props.remove("clientPort"); | ||
| props.remove("clientPortAddress"); | ||
| } | ||
| setDefault(props, "serverCnxnFactory", NettyServerCnxnFactory.class.getName()); |
There was a problem hiding this comment.
🤖 AI text below 🤖
An explicit NIO factory is left in place when an existing listener is converted to TLS, but ZooKeeper’s NIO factory cannot open a secure listener. Could startup reject incompatible explicit server or client transport settings with a message that tells operators what to change?
There was a problem hiding this comment.
@nick-boss-tech A question - you made 11 review comments on this PR, which generated 11 [email protected] emails to everyone. Github has a review "batch" option where you register each review comment as a pending draft and then submit them all in one go. Two benefits: One email instead of 11, less noise, and the review is also grouped in the UI rather than spread out. Possible?
| "trustStore", | ||
| EnvUtils.getProperty("solr.jetty.truststore", "./etc/solr-ssl.keystore.jks"), | ||
| EnvUtils.getProperty("solr.jetty.truststore.type", "PKCS12"), | ||
| ssl.getTrustStorePassword()); |
There was a problem hiding this comment.
🤖 AI text below 🤖
Jetty decodes obfuscated passwords supplied by its credential provider, but ZooKeeper receives the derived value verbatim here. Could inherited Jetty values be normalized before opening the ZooKeeper stores, without changing explicitly supplied ZooKeeper passwords?
| EnvUtils.getProperty("solr.jetty.truststore.type", "PKCS12"), | ||
| ssl.getTrustStorePassword()); | ||
| configureContextSupplier(props, useSolrTrustStore); | ||
| setDefault(props, "ssl.clientAuth", "none"); |
There was a problem hiding this comment.
🤖 AI text below 🤖
ZooKeeper requires a client certificate when ssl.clientAuth is unset. This default also applies to listeners already configured in zoo.cfg, so upgrading can change their authentication policy. Could none apply only to the listener Solr creates automatically?
| certificates.load(null, null); | ||
| for (String alias : Collections.list(store.aliases())) { | ||
| var certificate = store.getCertificate(alias); | ||
| if (certificate != null) certificates.setCertificateEntry(alias, certificate); |
There was a problem hiding this comment.
🤖 AI text below 🤖
This copies certificates from key entries into the trust-anchor set, which differs from ZooKeeper’s normal PKIX setup. Could the new path preserve the same trust anchors and add a test that verifies revocation is enforced, not just that a handshake succeeds?
| String bindHost = EnvUtils.getProperty("solr.zookeeper.embedded.host", "127.0.0.1"); | ||
| if (props.containsKey("clientPort")) props.setProperty("clientPortAddress", bindHost); | ||
| if (props.containsKey("secureClientPort")) { | ||
| props.setProperty("secureClientPortAddress", bindHost); |
There was a problem hiding this comment.
🤖 AI text below 🤖
This overwrites secureClientPortAddress even when the value was explicitly set in zoo.cfg. An existing secure listener can move to loopback on upgrade and lose its joining nodes. Could the Solr bind address be a fallback for an already-configured secure listener?
| if (zkServer.isClientSecure()) { | ||
| System.setProperty(ZKClientConfig.SECURE_CLIENT, "true"); | ||
| } | ||
| SSLConfigurationsFactory.current().initZooKeeper(); |
There was a problem hiding this comment.
🤖 AI text below 🤖
ZooKeeper publishes parsed server SSL settings as zookeeper.* system properties before client initialization. The client then treats those server values as explicit overrides, which can discard the separate outbound store settings. Could the server and client defaults stay separate while preserving intentional ZooKeeper overrides?
| List<String> response = in.lines().collect(Collectors.toList()); | ||
| log.debug("Got response from ZK on host {} and port {}: {}", host, port, response); | ||
| return response; | ||
| boolean zkClientSecure = EnvUtils.getPropertyAsBool(ZKClientConfig.SECURE_CLIENT, false); |
There was a problem hiding this comment.
🤖 AI text below 🤖
The status handler can take its addresses from ZooKeeper’s dynamic ensemble metadata. In a dual-port ensemble that metadata can advertise the plain client port, so the probe can report a healthy TLS ensemble as down. Could TLS probes use the secure connect string when the metadata does not identify secure ports?
| } | ||
| } | ||
| SSLConfigurationsFactory.current().init(); | ||
| SSLConfigurationsFactory.current().initZooKeeper(); |
There was a problem hiding this comment.
🤖 AI text below 🤖
ZooKeeper’s store paths are initialized before the CLI parses arguments here. If the effective SSL settings use relative store paths (for example, a path under etc/), ZooKeeper can resolve them against the process working directory instead of the Solr home or path the CLI is about to establish. Could the entry points resolve the store paths before this initialization?
| SOLR_SSL_CLIENT_TRUST_STORE="$TUTORIAL_HOME/tls/untrusted-truststore.p12" \ | ||
| SOLR_LOGS_DIR="$TUTORIAL_HOME/node2/logs" \ | ||
| bin/solr start -p 8984 --solr-home "$TUTORIAL_HOME/node2/solr" -z localhost:9983 | ||
| bin/solr start -p 8984 --solr-home "$TUTORIAL_HOME/node2/solr" -z localhost:9983/solr |
There was a problem hiding this comment.
🤖 AI text below 🤖
This step replaces node 2’s outbound trust before it joins the TLS-only ZooKeeper, so the node can fail startup before the distributed HTTPS query. Could the tutorial leave ZooKeeper trust intact for this check, or show the ZooKeeper startup failure as the expected result?
| done | ||
|
|
||
| run env SOLR_INCLUDE="$SOLR_HOME/tls/solr.in.sh" solr zk ls / --zk-host "localhost:$ZK_PORT" | ||
| run env SOLR_INCLUDE="$SOLR_HOME/tls/solr.in.sh" solr zk ls / --zk-host "localhost:$ZK_PORT/solr" |
There was a problem hiding this comment.
🤖 This PR extends the secure-example test in test_secure_example.bats with checks for the TLS-only embedded ZooKeeper: the chroot, the ZK status page, zoo.cfg contents, plain clients timing out, and automatic TLS on a normal HTTPS start. BATS is going away: CATS (SOLR-18642, #5323) has replaced it on main, and SOLR-18645 (#5369) removes the .bats files. Please port these checks to SecureExampleTest in solr/packaging/src/test/org/apache/solr/shell/. It is a nightly test, so run it with -Ptests.nightly=true. See dev-docs/cats.adoc for porting help.
https://issues.apache.org/jira/browse/SOLR-18659
Summary
-z/--zk-host), the embedded ZooKeeper's client port now accepts TLS only. Solr configures this in Java at startup, in memory: theclientPortbecomes a NettysecureClientPortusing Solr's HTTPS keystore, truststore, and SSL credential providers.zoo.cfgand the include file are not rewritten, and no password files are created. This is a behavior change on upgrade for any such deployment, with bothbin/solrandbin/solr.cmd.bin/solrCLI commands must add-Dzookeeper.client.secure=true(toSOLR_OPTSandSOLR_TOOL_OPTSrespectively); Solr then derives thezookeeper.ssl.*client settings from thejavax.net.ssl.*ones.ZookeeperStatusHandler(the Admin UI's ZooKeeper status page, SOLR-14027) now uses a TLS socket for its four-letter-word commands whenzookeeper.client.secureis set. Two known limitations are left as TODOs: its cached SSL context isn't rebuilt when a keystore or truststore is replaced, and hostnames the JDK rejects for SNI (such aszoo_1) fail the request.NodeConfig's startup ZooKeeper connection check, since that ZooKeeper isn't running yet. This makes-DzkHost, including a chroot, usable with the embedded ZooKeeper; previously that startup always timed out.SecurityAwareZkACLProvidernow handles the root namespace (no chroot), with a new unit test.bin/solr start -e secureexample and the securing-Solr tutorial (from SOLR-18527: Provide a example of a secure Solr using bin/solr start -e secure #5306) rely on the automatic TLS instead of configuring it by hand, and use a/solrZooKeeper chroot.Originally tracked under SOLR-18527 (now closed/merged for the base secure example); this follow-on work is tracked under SOLR-18659.
Test plan
test_secure_example.batspasses: the Admin UI ZooKeeper status endpoint against the TLS-only embedded ZooKeeper, the/solrchroot, ACL checks, and a plainbin/solr start -cwith HTTPS and no-zSolrZkServerTest,SSLConfigurationsTest,ZookeeperSSLContextSupplierTest,NodeConfigZookeeperTlsTest,ZookeeperStatusHandlerSocketTest,SecurityAwareZkACLProviderTest-DzkHostchanges)bin/solr.cmdwith HTTPS and embedded ZooKeeper (untested)🤖 Generated with Claude Code
https://claude.ai/code/session_018RwsEje8u9apx3SRzissZm