Repository navigation
GH-1499: [JDBC] Prefer an explicit trustStore over the system trust store - #1496
Merged
Merged
Conversation
useSystemTrustStore defaults to true and was checked before trustStore, so a configured trustStore was ignored unless useSystemTrustStore=false was also set, and the server was validated against the system trust store instead. Check trustStore first, as tlsRootCerts already is.
Arawoof06
requested review from
jbonofre,
laurentgo,
lidavidm and
wgtmac
as code owners
November 17, 2026 07:45
This comment has been minimized.
This comment has been minimized.
jbonofre
approved these changes
Nov 18, 2026
jbonofre
left a comment
Member
There was a problem hiding this comment.
LGTM on the code, test, and documentation changes. Good catch on useSystemTrustStore shadowing an explicit trustStore by default.
One process item before merging: per CONTRIBUTING.md, functional/bug-fix changes should be linked to a GitHub issue rather than using the MINOR: prefix.
If you don't mind, I will create an issue and update PR title.
jbonofre
added a commit
that referenced
this pull request
Nov 19, 2026
… values and missing password (#1501) ## What's Changed Follow-up to #1496 (#1499). - Treat blank `trustStore` and `tlsRootCerts` values as unset (`null`) in `ArrowFlightConnectionConfigImpl` and `ArrowFlightSqlClientHandler.Builder` (consistent with `hostnameOverride`), so empty query parameters or blank optional properties (e.g., `?trustStore=&useSystemTrustStore=true` or `?tlsRootCerts=&trustStore=...`) do not shadow fallback trust sources or fail trying to open an empty path. - Validate `trustStorePassword != null` in `ArrowFlightSqlClientHandler.Builder#build()` before calling `ClientAuthenticationUtils.getCertificateStream(...)`, so configuring `trustStore` without `trustStorePassword` throws `SQLException` (wrapping `IllegalArgumentException`) and closes the connection allocator instead of leaking an uncaught `NullPointerException`. - Sync Javadoc on `ArrowFlightSqlClientHandler.Builder#withSystemTrustStore`, `#withTrustStorePath`, and `#withTlsRootCertificates`, and clarify precedence and blank-value handling in `docs/source/flight_sql_jdbc_driver.rst`. - Tighten `ConnectionTlsTest#testGetAuthenticatedEncryptedConnectionWithKeyStoreBadPassword` to assert the `IOException` -> `UnrecoverableKeyException` cause chain, and add unit/connection tests for blank `trustStore`/`tlsRootCerts` and missing `trustStorePassword`. ## Tests - Ran `ConnectionTlsTest`, `ConnectionTlsRootCertsTest`, `ConnectionTlsHostnameOverrideTest`, `ConnectionMutualTlsTest`, `ArrowFlightSqlClientHandlerBuilderTest`, and `ArrowFlightConnectionConfigImplTest` on JDK 17, 21, and 25, plus `spotless:check` and `checkstyle:check`. Closes #1500.
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.
What's Changed
ArrowFlightSqlClientHandler.Builder.build()picks the TLS trust source in the ordertlsRootCerts,useSystemTrustStore,trustStore.useSystemTrustStoredefaults to true, so a connection configured withtrustStoreandtrustStorePasswordbut withoutuseSystemTrustStore=falsenever reads that trust store. The server is validated against the system store instead, which is opened with the trust store's password. When that password matches the JDKcacerts(changeit), or on Windows and macOS where the system keychains need none, any certificate chaining to a system CA is accepted even though the user limited trust to their own CA, and the handshake then sends the credentials to that server. Otherwise the connection fails with "Keystore was tampered with, or password was incorrect", which is why every existing test setsuseSystemTrustStore=falsenext totrustStore.An explicit
trustStorenow takes precedence over the system store, the same waytlsRootCertsalready does, and the docs sayuseSystemTrustStoreis ignored when either is set. Configurations that already setuseSystemTrustStore=falseare unaffected. The new test inConnectionTlsTestconnects withtrustStoreand the defaultuseSystemTrustStoreand fails without this change.testGetAuthenticatedEncryptedConnectionWithKeyStoreBadPasswordstill passes, now failing on the configured trust store rather than oncacerts.Closes #1499.