Search code examples
jdbcdb2

Add SSL Server Certificate for DB2 in JDBC code


I am trying to access a DB2 instance via SSL port. I have the certificate that I need to access it. But I am not sure of the parameter that I need to add it to so that connection is successful.

Dataset<Row> data=session.read().jdbc("jdbc:db2://url:port/DBNAME"+":sslConnection=true"        
    , "db2inst1.JOB_STATUS", connectionProperties);

    connectionProperties.put("driver", "com.ibm.db2.jcc.DB2Driver");
    connectionProperties.put("url", "jdbc:db2://url:port/DBNAME");
    connectionProperties.put("user", "db2inst1");
    connectionProperties.put("password", "xxxxx");

The python code to connect to the same DB2 instance is this :

"DATABASE=DB_NAME;HOSTNAME=url;SSL=TRUE;PORT=port;PROTOCOL=TCPIP;UID=xxxx;PWD=xxxx;SSLServerCertificate=DB2Certificate.arm;;SECURITY=SSL"

I would want to provide the DB2Certificate.arm as a parameter to the jdbc url , similar to the python parameter of SSLServerCertificate . How can I do this ?


Solution

  • Does the following URL work for you?
    jdbc:db2://url:port/DBNAME:sslConnection=true;sslCertLocation=/full_path/DB2Certificate.arm;