0

I've followed this document but unable to setup SSL JDBC connection. Getting exception

java.sql.SQLRecoverableException: IO Error: An established connection was aborted by the software in your host machine, connect lapse 16 ms., Authentication lapse 0 ms. at oracle.jdbc.driver.T4CConnection.handleLogonIOException(T4CConnection.java:915)

Currently my getConnection method looks as below: Can someone point me what is going wrong here?

public static java.sql.Connection getConnection(String user, String password) throws MalformedURLException, InstantiationException, IllegalAccessException, ClassNotFoundException
    {
        String trustStoreWalletPath="C://input//cwallet.sso" , keyStoreWalletPath="C://input//cwallet.sso";
        Security.addProvider(new oracle.security.pki.OraclePKIProvider());
        Security.insertProviderAt(new oracle.security.pki.OraclePKIProvider(),3);
        Properties property = new Properties();
        property.setProperty("oracle.net.authentication_services","(TCPS)");
        property.setProperty("javax.net.ssl.trustStore", trustStoreWalletPath);//
        property.setProperty("javax.net.ssl.trustStoreType", "SSO");
        property.setProperty("javax.net.ssl.keyStore", keyStoreWalletPath);
        property.setProperty("javax.net.ssl.keyStoreType", "SSO");
        String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=xx.dm.xyz.com)(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=xx.dm.xyz.com)))";
        property.setProperty("user", user);
        property.setProperty("password", password);

        try {
            Connection c = DriverManager.getConnection(url, property);
            return c;

        } catch (SQLException throwables) {
            throwables.printStackTrace();
            return null;
        }
    }

Found a SOF link but not answered. But this is exactly what I am trying.

lifeline2
  • 69
  • 1
  • 15

2 Answers2

1

Can you specify the JDBC driver version and database server version that you are using? Also, are you using oraclepki.jar, osdt_core.jar and osdt_cert.jar in the classpath? You can check out SSL blog for 12.2 and lower

Nirmala
  • 1,278
  • 1
  • 10
  • 11
  • yes I have ojdbc11.jar,oraclepki.jar, osdt_cert.jar and osdt_core.jar used as dependencies. I was forced to use ojdbc11.jar as seems SSL is not supported < ojdbc10.x.jar from https://docs.oracle.com/cd/E12517_01/back_office/pdf/141/html/pos_sg/appendix_jdbc_oracle.htm ( Caution: Ensure you are using ojdbc.jar version 10.2.x or later. Version 10.1.x or earlier will not connect over TCPS.). and ojbc11.jar is not available with java<11 so migrated to java11. But the problem still persists. I am unable to connect. There are suggestion about using tnsnames.ora and sqlnet.ora. m tryn thm! – lifeline2 Jul 21 '22 at 11:06
1

I know that Nirmala is supporting you as expected. However, beyond Oracle's official resources, there's a nice one here that might help you - https://www.thesslstore.com/blog/activate-ssl-oracle-jdbc-thin-driver/

Below you can find tips concerning how to debug SSL/TLS connections from the official Java SE docs as well. https://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/ReadDebug.html