0
votes

I am trying to connect to DB2 with SSL using Pyspark on Linux. I tried the following

user = "xxxx"
password = "xxxxx"
jdbcURL = "jdbc:db2://nn.nn.nnn.nnn:nnnn/<database>"
prop = {"user": user, "password": password, "driver": 
"com.ibm.db2.jcc.DB2Driver", "sslConnection": "true"}
table = "<schema>.<table name>"
df = spark.read.jdbc(url=jdbcURL, table=table, properties=prop)

I also tried

user = "xxxx"
password = "xxxxx"
jdbcURL = "jdbc:db2://nn.nn.nnn.nnn:nnnn/<database>"
prop = {"user": user, "password": password, "driver": 
"com.ibm.db2.jcc.DB2Driver", "sslConnection": "true"
"Security": "SSL", "SSLServerCertificate": "<path to arm file>"}}
table = "<schema>.<table name>"
df = spark.read.jdbc(url=jdbcURL, table=table, properties=prop)

I get the same error in both cases or socket output stream.

Error location: Reply.fill() - socketInputStream.read (-1). Message: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target. ERRORCODE=-4499, SQLSTATE=08001

I am not sure of the syntax to specify the .arm path. Stuck. Please help

Ganesh

P.S. I can connect with python and ibm_db module using

import ibm_db
conn = ibm_db.connect("DATABASE=<database> 
;HOSTNAME=nn.nn.nnn.nnn:nnnn;SECURITY=SSL;SSLServerCertificate=<path to arm 
file> ;UID=<user>;PWD=<password>","","")

This works.

1
Edit your question to specify the Db2-server version and platform (z/os , i-series, linux/unix/windows). Also specify your Db2-client (which supplies the Db2 jdbc driver) version and fixpack - mao
Also, have you configured your JRE correctly for SSL ? Follow docs at ibm.com/support/knowledgecenter/en/SSEPGG_11.1.0/… - mao
I am able to connect to SSL with python using ibm_db module. So the configuration is fine - Tinniam V. Ganesh
ibm_db module uses CLI (no java) , but pySpark uses JDBC , So DIFFERENT RULES, your configuration is suspect. - mao
@mao, what is the syntax for connecting to DB2 with SSL using Pyspark? - Tinniam V. Ganesh

1 Answers

0
votes

This was solved by re-installing the Java certificate.