title: IBMCloud - Connecting to PostgreSQL DB through JDBC (SSL Enabled)
body: <p>I am trying to connect to IBM Cloud PostgreSQL DB with Java (SSL Enabled. But while making a connection, i get the following error -</p>
  
  <pre><code>[7/31/19 10:48:46:952 UTC] 0000007a id=                                                                      R  org.postgresql.util.PSQLException: SSL error: Received fatal alert: handshake_failure
  [7/31/19 10:48:46:953 UTC] 0000007a id=                                                                      R      at org.postgresql.ssl.MakeSSL.convert(MakeSSL.java:42)
  [7/31/19 10:48:46:953 UTC] 0000007a id=                                                                      R      at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:441)
  [7/31/19 10:48:46:953 UTC] 0000007a id=                                                                      R      at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:94)
  [7/31/19 10:48:46:953 UTC] 0000007a id=                                                                      R      at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
  [7/31/19 10:48:46:954 UTC] 0000007a id=                                                                      R      at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
  [7/31/19 10:48:46:954 UTC] 0000007a id=                                                                      R      at org.postgresql.jdbc.PgConnection.&lt;init&gt;(PgConnection.java:195)
  [7/31/19 10:48:46:954 UTC] 0000007a id=                                                                      R      at org.postgresql.Driver.makeConnection(Driver.java:458)
  [7/31/19 10:48:46:954 UTC] 0000007a id=                                                                      R      at org.postgresql.Driver.connect(Driver.java:260)
  [7/31/19 10:48:46:954 UTC] 0000007a id=                                                                      R      at java.sql.DriverManager.getConnection(DriverManager.java:675)
  [7/31/19 10:48:46:955 UTC] 0000007a id=                                                                      R      at java.sql.DriverManager.getConnection(DriverManager.java:219)
  </code></pre>
  
  <p>I had followed docs - <a href="https://cloud.ibm.com/docs/services/databases-for-postgresql?topic=databases-for-postgresql-external-app&amp;locale=de" rel="nofollow noreferrer">https://cloud.ibm.com/docs/services/databases-for-postgresql?topic=databases-for-postgresql-external-app&amp;locale=de</a> to create the ssl certificate</p>
  
  <pre><code>Using the self-signed certificate
  Copy the certificate information from the Connections panel or the Base64 field of the connection information.
  If needed, decode the Base64 string into text.
  Save the certificate to a file. (You can use the Name that is provided or your own file name).
  Provide the path to the certificate to the driver or client.
  </code></pre>
  
  <pre><code>  String url = "jdbc:postgresql://**********.databases.appdomain.cloud:31260/ibmclouddb";
    Properties props = new Properties();
    props.setProperty("ssl","true"); 
    props.setProperty("user","ibm_cloud_********");
    props.setProperty("password","**************");
    props.setProperty("sslmode","verify-full");
    props.setProperty("sslcert","/opt/hb/postgres_cert/PGSSLCERT.crt");          props.setProperty("sslfactory","org.postgresql.ssl.jdbc4.LibPQFactory");
  </code></pre>