cloudera / hue

Open source SQL Query Assistant service for Databases/Warehouses
https://cloudera.com
Apache License 2.0
1.16k stars 364 forks source link

Cannot establish JDBC connection from Hue to Trino using SSL connection #3391

Closed deept-creditone closed 1 year ago

deept-creditone commented 1 year ago

Is there an existing issue for this?

Description

Hue version: 4.11 Trino version: 419

I am trying to connect Hue to Trino using JDBC connection. Earlier, we were using sqlalchemy but we are getting duplicate rows. Based on this suggestion I tried to connect. However, I am getting error while doing SSL verification.

Following is the configuration and request I am using:

interpreters: |- [[[trino]]] name = Trino interface=jdbc options= '{"url":"jdbc:trino://<coordinator-host/rout>:443/cdls?SSL=true&SSLTrustStorePath=/etc/cert/ca_truststore.jks&SSLTrustStorePassword=xxxxxxx","driver":"io.trino.jdbc.TrinoDriver","user":"trino-user","password"="xxxxx", "impersonation_property": "true" }'

Steps To Reproduce

  1. Install the necessary dependency. Mainly the py4j.
  2. Add trino jbdc driver jar in the classpath environment variable.
  3. You may not be able to see the error originating in java. Refer this to see full error stack.
  4. Use an SSL connection with jks file to establish a connection. You should be able to see the error.

Logs

[10/Jul/2023 13:36:15 -0700] decorators ERROR Error running create_session Traceback (most recent call last): File "/usr/share/hue/desktop/libs/notebook/src/notebook/decorators.py", line 119, in wrapper return f(*args, **kwargs) File "/usr/share/hue/desktop/libs/notebook/src/notebook/api.py", line 115, in create_session response['session'] = get_api(request, session).create_session(lang=session['type'], properties=properties) File "/usr/share/hue/desktop/libs/notebook/src/notebook/connectors/jdbc.py", line 85, in create_session if self.db is None or not self.db.test_connection(throw_exception='password' not in properties): File "/usr/share/hue/desktop/libs/librdbms/src/librdbms/jdbc.py", line 85, in test_connection self.connect() File "/usr/share/hue/desktop/libs/librdbms/src/librdbms/jdbc.py", line 101, in connect self.conn = self.gateway.jvm.java.sql.DriverManager.getConnection(self.db_url, self.username, self.password) File "/usr/share/hue/build/env/lib/python3.8/site-packages/py4j/java_gateway.py", line 1322, in call return_value = get_return_value( File "/usr/share/hue/build/env/lib/python3.8/site-packages/py4j/protocol.py", line 326, in get_return_value raise Py4JJavaError( py4j.protocol.Py4JJavaError: An error occurred while calling z:java.sql.DriverManager.getConnection. : java.sql.SQLException: Error setting up SSL: Keystore was tampered with, or password was incorrect at io.trino.jdbc.TrinoDriverUri.setupClient(TrinoDriverUri.java:358) at io.trino.jdbc.NonRegisteringTrinoDriver.connect(NonRegisteringTrinoDriver.java:56) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:681) at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244) at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:374) at py4j.Gateway.invoke(Gateway.java:282) at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132) at py4j.commands.CallCommand.execute(CallCommand.java:79) at py4j.GatewayConnection.run(GatewayConnection.java:238) at java.base/java.lang.Thread.run(Thread.java:833) Caused by: io.trino.jdbc.$internal.client.ClientException: Error setting up SSL: Keystore was tampered with, or password was incorrect at io.trino.jdbc.$internal.client.OkHttpUtil.setupSsl(OkHttpUtil.java:237) at io.trino.jdbc.TrinoDriverUri.setupClient(TrinoDriverUri.java:283) ... 14 more Caused by: java.io.IOException: Keystore was tampered with, or password was incorrect at java.base/sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:813) at java.base/sun.security.util.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:242) at java.base/java.security.KeyStore.load(KeyStore.java:1473) at io.trino.jdbc.$internal.client.OkHttpUtil.loadTrustStore(OkHttpUtil.java:285) at io.trino.jdbc.$internal.client.OkHttpUtil.setupSsl(OkHttpUtil.java:215) ... 15 more Caused by: java.security.UnrecoverableKeyException: Password verification failed at java.base/sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:811) ... 19 more

Hue version

4.11

bjornalm commented 1 year ago

@deept-creditone Thanks for reporting. We will try to have someone look into this.

@Harshg999 or @agl29 do you any ideas?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity and is not labeled "Prevent stale". Remove "stale" label or comment or this will be closed in 10 days.

Lynoge commented 3 weeks ago

Have you managed to solve this problem? I'm getting this error "could not find py4j jar at" in hue version 4.11. In 4.9 it doesn't happen and I can establish a connection and execute a query in trino 448