Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/source/flight_sql_jdbc_driver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ case-sensitive. The supported parameters are:

* - useSystemTrustStore
- true
- When TLS is enabled, whether to use the system certificate store
- When TLS is enabled, whether to use the system certificate store.
Ignored when ``trustStore`` or ``tlsRootCerts`` is set.

* - retainCookies
- true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1154,14 +1154,14 @@ public ArrowFlightSqlClientHandler build() throws SQLException {
if (tlsRootCertificatesPath != null) {
clientBuilder.trustedCertificates(
ClientAuthenticationUtils.getTlsRootCertificatesStream(tlsRootCertificatesPath));
} else if (useSystemTrustStore) {
clientBuilder.trustedCertificates(
ClientAuthenticationUtils.getCertificateInputStreamFromSystem(
trustStorePassword));
} else if (trustStorePath != null) {
clientBuilder.trustedCertificates(
ClientAuthenticationUtils.getCertificateStream(
trustStorePath, trustStorePassword));
} else if (useSystemTrustStore) {
clientBuilder.trustedCertificates(
ClientAuthenticationUtils.getCertificateInputStreamFromSystem(
trustStorePassword));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,34 @@ public void testGetNonAuthenticatedEncryptedConnection() throws Exception {
}
}

/**
* Check that a configured trust store is used even when useSystemTrustStore is left at its
* default value, rather than being silently replaced by the system trust store.
*
* @throws Exception on error.
*/
@Test
public void testGetEncryptedConnectionWithTrustStoreAndDefaultSystemTrustStore()
throws Exception {
final Properties properties = new Properties();

properties.put(
ArrowFlightConnectionProperty.HOST.camelName(), FLIGHT_SERVER_TEST_EXTENSION.getHost());
properties.put(
ArrowFlightConnectionProperty.PORT.camelName(), FLIGHT_SERVER_TEST_EXTENSION.getPort());
properties.put(ArrowFlightConnectionProperty.USER.camelName(), userTest);
properties.put(ArrowFlightConnectionProperty.PASSWORD.camelName(), passTest);
properties.put(ArrowFlightConnectionProperty.USE_ENCRYPTION.camelName(), true);
properties.put(ArrowFlightConnectionProperty.TRUST_STORE.camelName(), trustStorePath);
properties.put(ArrowFlightConnectionProperty.TRUST_STORE_PASSWORD.camelName(), trustStorePass);

final ArrowFlightJdbcDataSource dataSource =
ArrowFlightJdbcDataSource.createNewDataSource(properties);
try (final Connection connection = dataSource.getConnection()) {
assertTrue(connection.isValid(300));
}
}

/**
* Check if an encrypted connection can be established successfully when connecting through the
* DriverManager using just a connection url.
Expand Down
Loading