title: Connecting to DB2 with SSL using Pyspark
body: <p>I am trying to connect to DB2 with SSL using Pyspark on Linux. I tried the following</p>
  
  <pre><code>user = "xxxx"
  password = "xxxxx"
  jdbcURL = "jdbc:db2://nn.nn.nnn.nnn:nnnn/&lt;database&gt;"
  prop = {"user": user, "password": password, "driver": 
  "com.ibm.db2.jcc.DB2Driver", "sslConnection": "true"}
  table = "&lt;schema&gt;.&lt;table name&gt;"
  df = spark.read.jdbc(url=jdbcURL, table=table, properties=prop)
  </code></pre>
  
  <p>I also tried</p>
  
  <pre><code>user = "xxxx"
  password = "xxxxx"
  jdbcURL = "jdbc:db2://nn.nn.nnn.nnn:nnnn/&lt;database&gt;"
  prop = {"user": user, "password": password, "driver": 
  "com.ibm.db2.jcc.DB2Driver", "sslConnection": "true"
  "Security": "SSL", "SSLServerCertificate": "&lt;path to arm file&gt;"}}
  table = "&lt;schema&gt;.&lt;table name&gt;"
  df = spark.read.jdbc(url=jdbcURL, table=table, properties=prop)
  </code></pre>
  
  <p>I get the same error in both cases
  or socket output stream.  </p>
  
  <blockquote>
    <p>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</p>
  </blockquote>
  
  <p>I am not sure of the syntax to specify the .arm path. Stuck. Please help</p>
  
  <p>Ganesh</p>
  
  <p>P.S. I can connect with python and ibm_db module using </p>
  
  <pre><code>import ibm_db
  conn = ibm_db.connect("DATABASE=&lt;database&gt; 
  ;HOSTNAME=nn.nn.nnn.nnn:nnnn;SECURITY=SSL;SSLServerCertificate=&lt;path to arm 
  file&gt; ;UID=&lt;user&gt;;PWD=&lt;password&gt;","","")
  </code></pre>
  
  <p>This works.</p>