title: Java JDBC unable to connect to a Oracle database with SSL
body: <p>I have configured a Oracle 11g database server to work with SSL using a wallet and self signed certificate.
  Tested it with local client (sqlplus) and it works without any issues.
  Now I'm trying to connect the database using Java JDBC.
  Currently I'm getting an error:</p>
  
  <pre><code>Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to
  find valid certification path to requested target
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>public static void main(String[] args)
  {
      Connection connection = null;
  
      String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=192.168.200.191)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=VDB)))";
  
      Properties props = new Properties();
      props.setProperty("user", "dbuser");
      props.setProperty("password", "dbpass");
      props.setProperty("oracle.net.ssl_cipher_suites","(SSL_RSA_WITH_3DES_EDE_CBC_SHA)");
  
      /* Load the database driver */
      try
      {
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          connection = DriverManager.getConnection(url,props);
          if (connection != null) {
              System.out.println("You made it, take control your database now!");
          } else {
              System.out.println("Failed to make connection!");
          }
      }
      catch (SQLException ex) {
         ex.printStackTrace();
      }
  }
  </code></pre>
  
  <p>I did some more research, and found that if the wallet is configured as 'auto_login', I can try the following:</p>
  
  <pre><code>   Connection connection = null;
  
     String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=192.168.200.191)(PORT=1522))(CONNECT_DATA=(SERVICE_NAME=VDB)))";
  
      Properties props = new Properties();
      props.setProperty("user", "dbuser");
      props.setProperty("password", "dbpass");
      props.setProperty("javax.net.ssl.trustStore", "C:\\oracle\\wallet\\cwallet.sso");
      props.setProperty("javax.net.ssl.trustStoreType","SSO");
  
      /* Load the database driver */
      try
      {
          DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
          connection = DriverManager.getConnection(url,props);
          if (connection != null) {
              System.out.println("You made it, take control your database now!");
          } else {
              System.out.println("Failed to make connection!");
          }
      }
      catch (SQLException ex) {
      ex.printStackTrace();
  }
  </code></pre>
  
  <p>In this case, I'm getting:</p>
  
  <pre><code>java.security.NoSuchAlgorithmException: SSO KeyStore not available
  </code></pre>
  
  <p>I've added 3 Jars: oraclepki.jar, osdt_cert.jar, osdt_core.jar
  Attempted to run the last version of the code, getting exception:</p>
  
  <pre><code>java.lang.ClassNotFoundException: com.phaos.crypto.AuthenticationException
  </code></pre>
  
  <p>Perhaps I should specify the wallet location? as I did in the tnsnames.ora file? or specify the certificate CN?</p>
  
  <p>Please advise, thanks.</p>