Skip to content

Commit d64eddc

Browse files
dev-lpqpan3793
authored andcommitted
[KYUUBI #5713] Backport HIVE-27271: Client connection to HS2 fails when transportMode=http, ssl=true, sslTrustStore specified without trustStorePassword in the JDBC URL
# 🔍 Description Backport apache/hive#4262 ## Issue References 🔗 This pull request fixes ##5713 ## Describe Your Solution 🔧 trustStorePassword is not a necessary parameter in connection URL. Connection can be established without it. From the javadocs [Link](https://docs.oracle.com/javase/7/docs/api/java/security/KeyStore.html#load(java.io.InputStream,%20char%5B%5D)) A password may be given to unlock the keystore (e.g. the keystore resides on a hardware token device), or to check the integrity of the keystore data. If a password is not given for integrity checking, then integrity checking is not performed. In order to create an empty keystore, or if the keystore cannot be initialized from a stream, pass null as the stream argument. Reference PR comes from HIVE-27271 ## Types of changes 🔖 - [x] Bugfix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) ## Test Plan 🧪 #### Behavior Without This Pull Request ⚰️ #### Behavior With This Pull Request 🎉 #### Related Unit Tests --- # Checklists ## 📝 Author Self Checklist - [ ] My code follows the [style guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html) of this project - [ ] I have performed a self-review - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html) ## 📝 Committer Pre-Merge Checklist - [x] Pull request title is okay. - [x] No license issues. - [x] Milestone correctly set? - [ ] Test coverage is ok - [x] Assignees are selected. - [x] Minimum number of approvals - [x] No changes are requested **Be nice. Be informative.** Closes #5712 from dev-lpq/ssl_http_store. Closes #5713 c1011e4 [pengqli] Support client connection when transportMode=http,ssl=true, sslTrustStore specified without trustStorePassword in the JDBC URL Authored-by: pengqli <pengqli@cisco.com> Signed-off-by: Cheng Pan <chengpan@apache.org> (cherry picked from commit 0bcd107) Signed-off-by: Cheng Pan <chengpan@apache.org>
1 parent 809d4a1 commit d64eddc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kyuubi-hive-jdbc/src/main/java/org/apache/kyuubi/jdbc/hive/KyuubiConnection.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,8 @@ public long getRetryInterval() {
559559
// Pick trust store config from the given path
560560
sslTrustStore = KeyStore.getInstance(SSL_TRUST_STORE_TYPE);
561561
try (FileInputStream fis = new FileInputStream(sslTrustStorePath)) {
562-
sslTrustStore.load(fis, sslTrustStorePassword.toCharArray());
562+
sslTrustStore.load(
563+
fis, sslTrustStorePassword != null ? sslTrustStorePassword.toCharArray() : null);
563564
}
564565
sslContext = SSLContexts.custom().loadTrustMaterial(sslTrustStore, null).build();
565566
socketFactory =
@@ -685,7 +686,8 @@ SSLConnectionSocketFactory getTwoWaySSLSocketFactory() throws SQLException {
685686
SSL_TRUST_STORE + " Not configured for 2 way SSL connection");
686687
}
687688
try (FileInputStream fis = new FileInputStream(trustStorePath)) {
688-
sslTrustStore.load(fis, trustStorePassword.toCharArray());
689+
sslTrustStore.load(
690+
fis, trustStorePassword != null ? trustStorePassword.toCharArray() : null);
689691
}
690692
trustManagerFactory.init(sslTrustStore);
691693
SSLContext context = SSLContext.getInstance("TLS");

0 commit comments

Comments
 (0)