简体   繁体   English

JDBC SSL 与 Oracle 连接期间出现异常

[英]Exception during JDBC SSL connection with Oracle

I've followed this document but unable to setup SSL JDBC connection.我已关注此文档,但无法设置 SSL JDBC 连接。 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. java.sql.SQLRecoverableException: IO 错误:已建立的连接被主机中的软件中止,连接失效 16 毫秒,身份验证at oracle.jdbc.driver.T4CConnection.handleLogonIOException(T4CConnection.java:915)在 oracle.jdbc.driver.T4CConnection.handleLogonIOException(T4CConnection.java:915)

Currently my getConnection method looks as below: Can someone point me what is going wrong here?目前我的 getConnection 方法如下所示:有人能指出我这里出了什么问题吗?

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.找到一个 SOF 链接,但没有得到答复。 But this is exactly what I am trying.但这正是我正在尝试的。

Can you specify the JDBC driver version and database server version that you are using?您能指定您正在使用的 JDBC 驱动程序版本和数据库服务器版本吗? Also, are you using oraclepki.jar, osdt_core.jar and osdt_cert.jar in the classpath?另外,您是否在类路径中使用 oraclepki.jar、osdt_core.jar 和 osdt_cert.jar? You can check out SSL blog for 12.2 and lower您可以查看12.2 及更低版本的 SSL 博客

I know that Nirmala is supporting you as expected.我知道 Nirmala 正如预期的那样支持你。 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/但是,除了 Oracle 的官方资源之外,这里还有一个不错的资源可能会对您有所帮助 - 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.您还可以在下面找到有关如何从官方 Java SE 文档中调试 SSL/TLS 连接的提示。 https://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/ReadDebug.html https://docs.oracle.com/javase/7/docs/technotes/guides/security/jsse/ReadDebug.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM