Exception during JDBC SSL connection with Oracle

835 views Asked by At

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.

2

There are 2 answers

1
Nirmala On

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

0
Juarez Junior On

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